SV: Passing the value of a variable from PHP to JavaScript.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

Where is the value of $vtes comming from? If it's a parameter in the
call of your script, try something like
<?php
$vtes = $_GET["vtes"];
echo ....

Or even better dont use php to echo all of your javascript or html, but
just the relevant values, like this:

<html>
<script language='JavaScript'>
function tes(){
document.write('<p>JavaScript</p>');
window.location.replace('http://192.168.23.1/coba/coba.php?vtes=<?=$_GET
["vtes"]?>');

}
</script>
<body>
diforward ke javascript
<select onchange='tes()' name='vtes'>
<option value=''></option>
<option value='1'>1</option>
<option value='2'>2</option>
</select>
</body>
</html>

Hth Henrik Hornemann

-----Oprindelig meddelelse-----
Fra: Prabu Subroto [mailto:prabusubroto@xxxxxxxxxxxxx] 
Sendt: 27. februar 2004 10:03
Til: php-db@xxxxxxxxxxxxx
Emne:  Passing the value of a variable from PHP to JavaScript.


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.
-- 
_____________________________________________________________
Web-based SMS services available at http://www.operamail.com. From your
mailbox to local or overseas cell phones.

Powered by Outblaze

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux