to "access" php var in javascript, you'll need to set up javascript vars
with the values of the php vars you want to use.

eg.

<?
  $foobar = "testing";
?>
<script>
  alert(foobar);  // will display nothing - not set yet
  foobar = "<?= $foobar; ?>";
  alert(foobar);  // now will display "testing"
</script>

remember, to get the vars back to php, you'll need to make a request to the
server using one of serveral methods

hope that helps
Martin

-----Original Message-----
From: Don [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, February 06, 2002 9:00 AM
To: php list
Subject: [PHP] How do I display variables in text boxes when the value
of a drop down menu changes?


Hi,

I have a PHP script that displays a form.  On one section of the form, there
is a drop down menu followed by a few text boxes.  I'd like to alter the
values of the text boxes when the user changes the selection in the dropdown
menu.

What I've done is create 10 arrays (the drop down menu has 10 items hence
one array per item).  Each time the user changes the selection in the drop
down menu, I figure I'd:

a) save the current variables to the array corfresponding to the old
selection
b) fill the text boxes with vales of the array corresponding to the new
selection

Is this possible using PHP?  I figure that since PHP is server side, I will
have to use JavaScript to provide some of the functionality I require but
how do I set and access PHP variables from JavaScript?

If the above is not workable, Is there another way I can accomplish this?

Thanks in advance,
Don

Reply via email to