how to post value from java script to Php?

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
valen53
Forum Contributor
Posts: 137
Joined: Tue Aug 27, 2002 9:29 am

how to post value from java script to Php?

Post by valen53 »

anyone know about how to post the value from java script to php ? i use onChange () to post value.

below code was syntax error when run in browser ... but i dunno which code are error . anyone can help me ?
Thank u

<?php
echo '
<script language="JavaScript1.2">
function browse(form)
{
var site = form.supplier_id.options[form.supplier_id.selectedIndex].value;
';

$query = "Select * from member where Name='$site'";
$result = mysql_query($query);
$row = mysql_fetch_array($result);

echo'
form.address.value = '.$row[Address].' ;
}
</script>
';
?>
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

javascript runs client-side, php server-side.
After the document is delivered, there is no connection between the client and the server. Neither can php access the clients HTML-DOM nor javascript php's variables and functions.
There has to be a new request to the server to transmit data back and forth.
I suggest setting the values of the form and then submitting it in the javascript-function.
Post Reply