javascript - How to select only one checkbox when data comes from database -


i want give permission user select 1 check box.

$jsqla = mysql_query("select * products id='$product_id'") or die(mysql_error()); $jfeta = mysql_fetch_assoc($jsqla);  $formats = explode(";", $jfeta['formats']);  <div class="">     <?php foreach($formats $v){ ?>         <label style="line-height: 1.25em;display: block;width: 100px;margin-right: 10px;float: left;">                                      <div class="fomat_buttons" style="border: 1px solid;border-radius: 9px;text-align: center;padding-top: 10px;padding-bottom:10px;padding-left: 3px;padding-right: 3px;border-color: #cccccc;font-family: 'ssemibold'; font-size: 13px; color: #44b7da;">                                          <input class="format_cheks" type="checkbox" value="<?php echo $v; ?>" style="visibility:hidden;"/>                               <span style="margin:-17px auto auto 0px;display:block;"><?php echo $v; ?></span>                                         </div>                               </label>     <?php } ?>  </div> 

i want give permission user select 1 check box

sounds want radio button group, not checkboxes.

<input class="format_cheks" type="radio" name="format_cheks" value="<?php echo $v; ?>" style="visibility:hidden;"/> <!-- changes here ---------------^^^^^^^^^^^^^^^^^^^^^^^^^^^                     --> 

the browser automatically deselect other name="format_cheks" radio button when user checks 1 of others. when form submitted, one format_cheks field sent, value of checked radio button (if any).

<div><label><input type="radio" name="foo" value="1"> one</label></div>  <div><label><input type="radio" name="foo" value="2"> two</label></div>  <div><label><input type="radio" name="foo" value="3"> three</label></div>


Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -