CodeIgniter Forums
my radio button not working properly? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: my radio button not working properly? (/showthread.php?tid=72182)



my radio button not working properly? - kvanaraj - 11-15-2018

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


RE: my radio button not working properly? - abGorad - 11-15-2018

<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


RE: my radio button not working properly? - kvanaraj - 11-16-2018

(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.


RE: my radio button not working properly? - Wouter60 - 11-16-2018

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???


RE: my radio button not working properly? - dave friend - 11-16-2018

(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.