php - keep radio button values and set default checked -


i have form radio button group. want set 'checked' default second radio button, , keep value after submitting form if user clicks on first one.

note i'm using <span class="custom-radiobutton"></span> style radiobuttons, lower z-index real <input type="radio", has opacity:0.

this snippet of code:

<div class="group-wrapper">   <div class="radiobutton-wrapper boolean">     <span class="custom-radiobutton"></span>     <input type="radio" id="hosting-1" name="hosting[]" value="1" class="w100" <?php if ((isset($_post['hosting'])) && ((isset($_post['hosting'])) == 1)) {echo 'checked="checked"';}; ?> />      <label for="hosting-1">sí</span>   </div>   <div class="radiobutton-wrapper boolean">     <span class="custom-radiobutton"></span>     <input type="radio" id="hosting-2" name="hosting[]" value="0" class="w100" <?php if ((!isset($_post['hosting'])) || ((isset($_post['hosting'])) == 0)) {echo 'checked="checked"';}; ?> />      <label for="hosting-2">no</label>   </div> </div> 

additional info:

  • i'm using html5.
  • i'm validating form php (i want keep this, if know maybe better jquery+php validation).
  • i have noticed need 2 clicks select first radio button. occurs original state. after this, works 1 click, expected.

i'm expending lot of hours trying figure out what's wrong, appreciated. cheers,

<input type="radio" id="hosting-1" name="hosting[]" class="w100"  checked="checked" /> 1 

try in code.

for example:

<tr>     <td><br><b>reservation handling :  <span style="color:#ff0000">* &nbsp;&nbsp;</span></td>     <td><br><input type="radio" name="reservation" value="delighted" required> delighted<br></input></td> </tr> <tr>     <td> </td>     <td><input type="radio" name="reservation" checked="checked" value="satisfied"> satisfied</input></td> </tr> <tr>     <td> </td>     <td><input type="radio" name="reservation" value="dissatisfied"> dissatisfied</input></td> </tr> <tr>     <td> </td>     <td><input type="radio" name="reservation" value="n/a"> n/a</input></td> </tr>        

Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -