blic Posted June 7, 2011 Share Posted June 7, 2011 Hi, I have 2 radio buttons and one field. I want to be able to, depending on the user clicking on the field, set the radio button to disabled before submitting the form. How do I do it? I have this, and I wanted the function set_radio to disable the radio buttons: $v1=$v2 = "" <input TYPE="radio" NAME="prtype" VALUE="nose" <?= $v1 ?>>Nose <input TYPE="radio" NAME="prtype" VALUE="mouth" <?= $v2 ?>>Mouth <input type="text" name="text1" maxlength="10" class="entry" onclick="set_radio()" value="<?= $text1 ?>"> function set_radio(){ //set v1 and v2 to disabled } I Link to comment https://forums.phpfreaks.com/topic/238718-set-radio-button/ Share on other sites More sharing options...
teynon Posted June 7, 2011 Share Posted June 7, 2011 This is a javascript task. <script> function set_radio() { document.getElementById('v1').disabled=true; document.getElementById('v2').disabled=true; } </script> <input id="v1" TYPE="radio" NAME="prtype" VALUE="nose">Nose <input id="v2" TYPE="radio" NAME="prtype" VALUE="mouth">Mouth <input type="text" name="text1" maxlength="10" class="entry" onclick="set_radio()" value="<?= $text1 ?>"> I believe it is .disabled = true, but I would verify that. Link to comment https://forums.phpfreaks.com/topic/238718-set-radio-button/#findComment-1226693 Share on other sites More sharing options...
blic Posted June 7, 2011 Author Share Posted June 7, 2011 I thought it would work with php using $_SESSION, but it was just a guess.. Link to comment https://forums.phpfreaks.com/topic/238718-set-radio-button/#findComment-1226707 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.