PerpsTherapy Posted December 14, 2006 Share Posted December 14, 2006 Greetings to all.Is there anyway to assertain whether a radio button has been selected without submitting the form it is a part of? I have two radio buttons that I want to act as a switch for displaying an additional text area element of the form when one of the radio buttons is selected, but not the other. Is it possible to determine whether a radio button has been selected without submitting the form?Many thanks,- PerpsTherapy Quote Link to comment https://forums.phpfreaks.com/topic/30605-checking-if-radio-buttons-have-been-selected-without-submitting-form/ Share on other sites More sharing options...
.josh Posted December 14, 2006 Share Posted December 14, 2006 not with php. you can with javascript though. moving to javascript forum. Quote Link to comment https://forums.phpfreaks.com/topic/30605-checking-if-radio-buttons-have-been-selected-without-submitting-form/#findComment-140923 Share on other sites More sharing options...
artacus Posted December 14, 2006 Share Posted December 14, 2006 I guess I'll wait and see if he finds his post before I answer. Quote Link to comment https://forums.phpfreaks.com/topic/30605-checking-if-radio-buttons-have-been-selected-without-submitting-form/#findComment-140927 Share on other sites More sharing options...
PerpsTherapy Posted December 14, 2006 Author Share Posted December 14, 2006 [quote author=artacus link=topic=118568.msg484598#msg484598 date=1166077861]I guess I'll wait and see if he finds his post before I answer.[/quote]Hehe, found my post. I wasn't aware it couldn't be done with php. How would one go about doing something like this with javascript??Many thanks,- Perpstherapy Quote Link to comment https://forums.phpfreaks.com/topic/30605-checking-if-radio-buttons-have-been-selected-without-submitting-form/#findComment-140962 Share on other sites More sharing options...
artacus Posted December 14, 2006 Share Posted December 14, 2006 PHP is a server side technology so you can control if a radio button is selected when it is sent off to the user's browser. But you need to check if a button is selected after the user has fooled around with it, so you need javascript.<input type="radio" name="myRadioBtn" value="1" />[code]function checkform() { for(var i=0; i<form1.myRadioBtn.length; i++) { if(form1.myRadioBtn[i].checked) { alert(form1.myRadioBtn[i].value); ...do something } }}[/code] Quote Link to comment https://forums.phpfreaks.com/topic/30605-checking-if-radio-buttons-have-been-selected-without-submitting-form/#findComment-140984 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.