rashmi_k28 Posted August 4, 2008 Share Posted August 4, 2008 How to open the page in another window when radio button value 4 is selected. When other option is selected open in same window. Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted August 4, 2008 Share Posted August 4, 2008 Okay question is rather brief. I don't really know exactly what you want but I took a stab: <script type="text/javascript"> function radioClick(v,link){ if(v.value == 4){ window.open(link,"new_page"); }else{ window.location=link; } } </script> <form> 1: <input type="radio" name="radio_group" id="radio1" value="1" onclick="javascript:radioClick(this,'http://www.linkhere.com')" /><br /> 2: <input type="radio" name="radio_group" id="radio2" value="2" onclick="javascript:radioClick(this,'http://www.linkhere.com')" /><br /> 3: <input type="radio" name="radio_group" id="radio3" value="3" onclick="javascript:radioClick(this,'http://www.linkhere.com')" /><br /> 4: <input type="radio" name="radio_group" id="radio4" value="4" onclick="javascript:radioClick(this,'http://www.linkhere.com')" /> </form> Quote Link to comment Share on other sites More sharing options...
lemmin Posted August 4, 2008 Share Posted August 4, 2008 I think he means more like this: <form id="frm1"> <input type="radio" name="rad1" value="1">Radio 1 <input type="radio" name="rad1" value="2">Radio 2 <input type="radio" name="rad1" value="3">Radio 3 <input type="radio" name="rad1" value="4">Radio 4 <br> <input type="submit" onclick="if (rad1[3].checked) frm1.target='_blank'"> </form> Quote Link to comment Share on other sites More sharing options...
rashmi_k28 Posted August 5, 2008 Author Share Posted August 5, 2008 yes, There is 4 radio button and one submit button. When radio button 4th option selected, I have to open somepage.html in another window. When radio button 1-3 option selected, it should open in same page. Quote Link to comment Share on other sites More sharing options...
rashmi_k28 Posted August 8, 2008 Author Share Posted August 8, 2008 function checkForm(TheForm) { if (document.example.date2.disabled == true) { if (document.example.date1.value == "yyyy-mm-dd") { var msg = "date not chosen from calendar icon"; alert(msg); return false; } } else{ if (document.example.date1.value == "yyyy-mm-dd" || document.example.date2.value == "yyyy-mm-dd") { var msg = "start or end date not chosen from calendar icon"; alert(msg); return false; } if(document.example.date1.value > document.example.date2.value){ var msg = "choose proper date-Start date is greater than end date"; alert(msg); return false; } if(document.example.date1.value == document.example.date2.value){ var msg = "choose proper date-Start and end date is equal"; alert(msg); return false; } if (document.example.opt2[3].checked && document.example.date2.value != "yyyy-mm-dd") { var msg="select only Start date- duration option not available"; alert(msg); return false; } } } <FORM NAME="example" class="frm" onreset="disableField()" onSubmit="return checkForm(this);" action="a.php"> Quote Link to comment Share on other sites More sharing options...
rashmi_k28 Posted August 8, 2008 Author Share Posted August 8, 2008 Please tell me when option4 radio button is selected and clicked the submit button it ahould open in another window. And options 1,2,3 in same window Quote Link to comment Share on other sites More sharing options...
lemmin Posted August 8, 2008 Share Posted August 8, 2008 That is what the code I posted four days ago does. Did you try it? Quote Link to comment Share on other sites More sharing options...
rashmi_k28 Posted August 9, 2008 Author Share Posted August 9, 2008 No when i use <form id="frm1"> all the radio buttons opens in new window not when only option 4 is selected Quote Link to comment Share on other sites More sharing options...
lemmin Posted August 11, 2008 Share Posted August 11, 2008 I just tested the code that I posted and it does exactly what you asked for. Quote Link to comment 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.