Form Variable Available on same page?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dwessell
Forum Commoner
Posts: 62
Joined: Fri Dec 23, 2005 2:30 pm

Form Variable Available on same page?

Post 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
User avatar
raghavan20
DevNet Resident
Posts: 1451
Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK
Contact:

Post 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
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post 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" .. >
Post Reply