Re: Passing the value of a variable from PHP to JavaScript.
| From: | Steve Davies | Date: | Fri, 27 Feb 2004 10:52:58 +0000 |
| Subject: | Re: Passing the value of a variable from PHP to JavaScript. | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-33179@lists.php.net to get a copy of this message | ||
Hi Prabu
you need to add a few bits:
in the function:
function tes(){
vtes = theform.vtes.value; #added line
document.write('<p>JavaScript</p>');
window.location.replace('http://127.0.0.1/coba/coba.php?vtes=' + vtes); #altered line
in the body:
<form name='theform'>
and </form> before the </html>
may be a bit ott but should work
steve
}
Prabu Subroto wrote:
Dear my friends... I have my code like this : ====== <?php echo " <html> <script language='JavaScript'> function tes(){ document.write('<p>JavaScript</p>'); window.location.replace('http://192.168.23.1/coba/coba.php?vtes=$vtes'); } </script> <body> "; echo "diforward ke javascript"; echo " <select onchange='tes()' name='vtes'> <option value=''></option> <option value='1'>1</option> <option value='2'>2</option> </select> "; ?> </body> </html> ====== I expect this result on url column of my internet browser: " http://192.168.23.1/coba/coba.php?vtes='1' " or " http://192.168.23.1/coba/coba.php?vtes='1' " But I only get this unexpected result: " http://192.168.23.1/coba/coba.php?vtes= " Lookslike the value of "$vtes" was not passed to JavaScript interpreter. Anybody of you have a solution for me? Please teach me. Thank you very much.