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.


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

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

-----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?


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

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
b) fill the text boxes with vales of the array corresponding to the new

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,

Reply via email to