CodeIgniter Forums

Full Version: my radio button not working properly?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Code:
<input type="radio" name="kvr"  checked="checked" onclick="hideall1();showit1('x1')"  <?php if (isset($_POST['kvr']) && $_POST['kvr']=="yes") echo "checked";?> value="yes"  >Same &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;

<input type="radio" name="kvr" onclick="hideall();showit('x1')"  <?php if (isset($_POST['kvr']) && $_POST['kvr']=="no") echo "checked";?> value="no" >Other

at first radio button click the form should not be submitted, after click second radio button  the value only be passed. why? need suggestion
<input type="radio" name="kvr"  checked="checked" onclick="hideall1();showit1('x1')"  <?php if (isset($_POST['kvr']) && $_POST['kvr']=="yes") echo "checked";?> value="yes"  >Same &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;

<input type="radio" name="kvr" onclick="hideall();showit('x1')"  <?php if (isset($_POST['kvr']) && $_POST['kvr']=="no") echo "checked";?> value="no" >Other

-----------------------

remove checked="checked" from first line
(11-15-2018, 05:00 AM)abGorad Wrote: [ -> ]<input type="radio" name="kvr"  checked="checked" onclick="hideall1();showit1('x1')"  <?php if (isset($_POST['kvr']) && $_POST['kvr']=="yes") echo "checked";?> value="yes"  >Same &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;

<input type="radio" name="kvr" onclick="hideall();showit('x1')"  <?php if (isset($_POST['kvr']) && $_POST['kvr']=="no") echo "checked";?> value="no" >Other

-----------------------

remove checked="checked" from first line

default first radio button should be checked when loading form.
Reading this question, I wonder why you keep ignoring the numerous advices that I and others have given you about the CI fundamentals, form validation library, form helper and jQuery. Why asking questions in a CI forum if you intend to stick to traditional php and javascript anyway???
(11-15-2018, 04:16 AM)kvanaraj Wrote: [ -> ]after click second radio button  the value only be passed. why?
If you are asking "Why is it only the value of the second radiobutton gets passed?"

If these are in a radiogroup. Only one radio button within the same radiogroup may be selected at a time. Only the value of the selected radio button will be sent to the server.

If you want multiple values you should probably be using checkbox.