Results 1 to 2 of 2

Thread: radio buttons and hidden fields

  1. #1
    Join Date
    Oct 2008
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default radio buttons and hidden fields

    I want to be able to use radio buttons on my form but I need the selected one to update 2 seperate fields in my database. I am attaching what I have tried, but didn't work. I am new to all of this, so please be gentle
    HTML Code:

    <INPUT class="element radio" id=element_5_1 type=radio value=Swee****er Golf and CC=Ub2venue> <input type="hidden" name="Ub2bwsdate" value="10/22/2008"/>
    <LABEL class=choice for=element_5_1>Oct. 22 6:30p.m. Swee****er Golf and Country Club, Apopka </LABEL>
    <INPUT class="element radio" id=element_5_2 type=radio value=Swee****er Golf and CC=Ub2venue> <input type="hidden" name="Ub2bwsdate" value="10/23/2008"/>
    <LABEL class=choice for=element_5_2>Oct. 23 2:30p.m. Swee****er Golf and County Club, Apopka </LABEL>
    <INPUT class="element radio" id=element_5_3 type=radio value=USBank, KC=Ub2venue> <input type="hidden" name="Ub2bwsdate" value="10/28/2008"/>
    <LABEL class=choice for=element_5_3>Oct. 28 2:30 p.m. USBank, Kansas City </LABEL>
    <LABEL class=choice for=element_5_4></LABEL> </SPAN>


    I need it to update field Ub2venue with the locaion and update the Ub2bwsdate field with the date from the selected one.

    Any help would be appreciated.

  2. #2
    Join Date
    Jul 2006
    Posts
    497
    Thanks
    8
    Thanked 70 Times in 70 Posts

    Default

    HTML requires that you quote any attribute values which contain spaces, and it's a good idea to quote all of them.

    Radio buttons and hidden fields cannot be associated in any way (without JavaScript), but you can use one HTML field to update two database fields.

    Finally, PHP can handle arrays in forms.
    HTML Code:
    <INPUT class="element radio" id="element[5][1]" type="radio" value="Swee****er Golf and CC=Ub2venue|10/22/2008">
    <LABEL class="choice" for="element[5][1]">Oct. 22 6:30p.m. Swee****er Golf and Country Club, Apopka </LABEL>
    <INPUT class="element radio" id="element[5][2]" type="radio" value="Swee****er Golf and CC=Ub2venue|10/23/2008">
    <LABEL class="choice" for="element[5][2]">Oct. 23 2:30p.m. Swee****er Golf and County Club, Apopka </LABEL>
    <INPUT class="element radio" id="element[5][3]" type="radio" value="USBank, KC=Ub2venue|10/28/2008">
    <LABEL class="choice" for="element[5][3]">Oct. 28 2:30 p.m. USBank, Kansas City </LABEL>
    In your PHP...
    PHP Code:
    $element $_POST['element'];
    for(
    $i 1$i <= count($element[5]); $i++){
        
    $element[5][$i] = explode('|'$_POST['element'][5][$i]);
        
    $location $element[5][$i][0];
        
    $date $element[5][$i][1];

    -- Chris
    informal JavaScript student of Douglas Crockford
    I like wikis - a lot.

Bookmarks

Posting Permissions

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