简体   繁体   中英

radio button value cant send via mail

First radio button only taken

     <div class="field_radio" name="preference" >
       <input class="radio1" type="radio" name="preference" id="preference" 
         value="team"  onclick="ShowHideDiv()" /><label for="radio1">
         <span>Team</span></label>
      <input class="radio2" type="radio" name="preference" id="preference" 
         value="individual" onclick="ShowHideDiv()" /> <label for="radio2">
         <span>Individual</span></label>
     </div> 

Php section

if (empty($_POST["preference"])) {
    $errorMSG .= "preference is required ";
} else {
    $preference = $_POST["preference"];
}

you took same id on both input field

<div class="field_radio" name="preference">
    <input class="radio1" type="radio" name="preference" id="preference_one"         value="team"  onclick="ShowHideDiv()" />
    <input class="radio2" type="radio" name="preference" id="preference_two" 
     value="individual" onclick="ShowHideDiv()" />
</div>
<div class="field_radio">
    <input type="radio" class="radio1" name="preference" id="preference1" value="team" onclick="ShowHideDiv()" />
    <label for="radio1"><span>Team</span></label>
    <input type="radio" class="radio2" name="preference" id="preference2" value="individual" onclick="ShowHideDiv()" />
    <label for="radio2"><span>Individual</span></label>
</div>

Note: Ids of the radio buttons are same make it different will solve your problem!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM