MDanz Posted August 7, 2009 Share Posted August 7, 2009 i have 8 radio buttons next to a text field. how do i do,... if radiobutton 1 is pressed then textfield 1 is shown. if radiobutton 2 is pressed then shown textfield 2 etc.? do i have to overlap the textfields? Link to comment https://forums.phpfreaks.com/topic/169197-text-field-radio-buttons/ Share on other sites More sharing options...
MDanz Posted August 7, 2009 Author Share Posted August 7, 2009 instead how do i do... if radiobutton 1 is selected. then bring submitbutton1 to the front? Link to comment https://forums.phpfreaks.com/topic/169197-text-field-radio-buttons/#findComment-892739 Share on other sites More sharing options...
deepson2 Posted August 7, 2009 Share Posted August 7, 2009 You can show the button is disable till someone clicks on the radio button and using java script function you can check whether the radio buttons value is selected or not. I have done something like this long time back. but it was not for submit button but if user clicks on radio button then he/she would be able to write something into respective text box. please check out the following code may it ll help you. php code: <td width="101%" valign="top" colspan="2">Habits and Lifestyles</td> </tr> <tr> <td width="50%" valign="top">Cigarettes</td> <td width="50%"> <p class="MsoNormal"><input type="radio" name="cigarette" value="Y" onClick="decide('enable')"><b> <input type="text" name="cigarette_per_day" size="20"></b> cigarettes/day × <input type="text" name="years_cigarette" size="20">year </p> <p><input type="radio" name="cigarette" value="N" onClick="decide('enable')"><b> </b>Quit since <input type="text" name="quit_cigarette_since" size="20">year after smoking/chewing for <input type="text" name="quit_cigarette_after" size="20">year </p></td> </tr> JS for this function decide(disorenable) { var num = document.cont.elements.length //var current = 0 if(disorenable == 'disable') { document.cont.cigarette_per_day.disabled = true document.cont.years_cigarette.disabled = true document.cont.tobacco_per_day.disabled = true document.cont.tobacco_years.disabled = true document.cont.quit_since.disabled = true document.cont.quit_after.disabled = true } else { document.cont.cigarette_per_day.disabled = false document.cont.years_cigarette.disabled = false document.cont.tobacco_per_day.disabled = false document.cont.tobacco_years.disabled = false document.cont.quit_since.disabled = false document.cont.quit_after.disabled = false } } Link to comment https://forums.phpfreaks.com/topic/169197-text-field-radio-buttons/#findComment-892762 Share on other sites More sharing options...
deepson2 Posted August 7, 2009 Share Posted August 7, 2009 See, i have checked the following code. Do you want to do somthing like this? <html> <head> <script> function decide3(disorenable) { var num = document.cont.elements.length //var current = 0 if(disorenable == 'disable') { document.cont.cups_per_day.disabled = true } else { document.cont.cups_per_day.disabled = false } } </script> </head> <body> <form action="<?=$PHP_SELF;?>" method="post" name="cont"> <table> <tr> <td width="50%" valign="top"> Tea/Coffee: </td> <td width="50%"><input type="radio" name="tea_coffee" value="N" onClick="decide3('disable')"> No <input type="radio" name="tea_coffee" value="Y" onClick="decide3('enable')"> Yes <input type="text" name="cups_per_day" size="20">cups/day</td> </tr> </form> </table> </body> </html> Link to comment https://forums.phpfreaks.com/topic/169197-text-field-radio-buttons/#findComment-892769 Share on other sites More sharing options...
MDanz Posted August 7, 2009 Author Share Posted August 7, 2009 yeh similar, i've changed it to make it easier for me... e.g. if radiobutton1 is pressed then bring forward layer1(which has the submit button). ^^ This way i can do as many submit buttons as i want because layers can overlap. The only problem i have is how to slot in the command if($_GET['RadioGroup1']== 1 ) \\bring layer1 to front whats the code to bring layers to the front? thx for the help btw Link to comment https://forums.phpfreaks.com/topic/169197-text-field-radio-buttons/#findComment-892794 Share on other sites More sharing options...
deepson2 Posted August 7, 2009 Share Posted August 7, 2009 if($_GET['RadioGroup1']== 1 ) Using this you must be storing your radio buttons value if i am not wrong. so i assume that you are doing something like this. So you can fetch the value and according to it you can adjust your code. Is this something similar you want that? Link to comment https://forums.phpfreaks.com/topic/169197-text-field-radio-buttons/#findComment-892833 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.