Page 1 of 1

Form Variable Available on same page?

Posted: Thu Jan 26, 2006 9:58 pm
by dwessell
Hi all..

Quick question here... In a form, can you make the selection on an input, available as a variable on the same page, without moving to another page?

Example:

Code: Select all

<select name="numberBeers">
<option> 1
<option> 2
</select>
If I want to provide the user differing options, depending on what they chose in the box above, is it possible without leaving that page?

Thanks
David

Posted: Thu Jan 26, 2006 10:00 pm
by raghavan20
options are accessible in the same page through javascript without page refresh
but if you want to access through any server side script you have to submit the form using GET or POST

Posted: Thu Jan 26, 2006 10:05 pm
by John Cartwright
I'm not sure what you mean by not leave the page..

If you mean without submitting the form, but you want to retrieve the value of the select box, then as raghavan mentioned you'll need some javascript..

If you mean can you submit the form to the current page? Yes you can.
It is a matter of setting the form action.. ie

Code: Select all

<form action="index.php" .. >