Visualizzazione dei risultati da 1 a 3 su 3
  1. #1

    Passare un valore ad una funzione javasript

    io ho questa funzione

    </style>
    <script language="JavaScript" type="text/JavaScript">
    function tlink() {
    var L = prompt("Inserisci il Testo del Link","");
    if (L != "" || null) {tlink_2(L);}
    }
    function tlink_2(L){
    var L_2 = prompt("inserisci l'URL","");
    if(L_2 != "" || null) {document.addpost.testo.value=document.addpost.tes to.value + '' + L + ' ' }
    document.addpost.testo.focus();
    }
    </script>

    Che funziona bene, ma vorrei passargli da php un valore... tipo vorrei che var L = $testo...

    è possibile? come posso fare?

  2. #2
    Utente di HTML.it L'avatar di gianiaz
    Registrato dal
    May 2001
    Messaggi
    8,027
    Intendi cosi?

    Codice PHP:
    echo "<script>tlink_2($L)</script>"

  3. #3
    Utente di HTML.it L'avatar di Grino
    Registrato dal
    Oct 2004
    Messaggi
    739
    oppure così

    codice:
    </style>
    <script language="JavaScript" type="text/JavaScript">
    function tlink() {
    var L = "<?= htmlspecialchars($testo)?>";//<--GUARDA QUI
    if (L != "" || null) {tlink_2(L);} 
    }
    function tlink_2(L){
    var L_2 = prompt("inserisci l'URL","");
    if(L_2 != "" || null) {document.addpost.testo.value=document.addpost.testo.value + '' + L + ' ' }
    document.addpost.testo.focus();
    }
    </script>

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.