View Full Version : Select value from listbox

09-14-2005, 02:26 AM
In my form i have a listbox which indicates the extract size of my zip file that is to be created. The option values in the listbox is hard-coded and not taken from the database. However, one of the option values are stored in the database, as a default extract size, which is one of the values of the hard-coded listbox.

And i would retrieve the default extract size from the database and make the option value selected, to show it is the default value. My question is how do i select a value in the listbox using php? Thank you

<select name="extractSize">
<option value="52428800">50MB</option>
<option value="41943040">40MB</option>
<option value="31457280">30MB</option>
<option value="20971520">20MB</option>
<option value="15728640">15MB</option>
<option value="10485760">10MB</option>
<option value="5242880">5MB</option>

09-14-2005, 04:25 AM
Your PHP variable will be called $extractSize. Its value will be whichever listbox option you click on in the HTML form. For example, if you clicked on the 15MB option, the value of $extractSize would be 15728640.

Hope this helps. :)

09-14-2005, 09:06 PM
Only if you have register_globals on, which is a no no. The correct variable will be either be $_GET['extractSize'] or $_POST['extractSize'] depending on how you set the method in the form.

If all else fails, $_REQUEST['extractSize'] will work.