Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Aug 2005
    Thanked 0 Times in 0 Posts

    Select value from listbox

    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>

  • #2
    $object->toCD-R(LP); vinyl-junkie's Avatar
    Join Date
    Jun 2003
    Thanked 23 Times in 23 Posts
    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.
    Music Around The World - Collecting tips, trade
    and want lists, album reviews, & more
    SNAP to it!

  • #3
    Regular Coder
    Join Date
    Aug 2004
    The US of A
    Thanked 0 Times in 0 Posts
    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.


    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts