How Do I open an website/url using radio button option? for ex: 1) yahoo 2) google 3) msn if clicked on radio button option 1) it's suppose to open yahoo site in same window or another window. similarly if i clicked/selected radio button 3) then msn site is suppose to open. So how is it? please give a demo with script tutorial! thanks for ur real replies with right solutions.
Without a submit button, you'll be requiring the use of Ajax or Javascript to sort out this. <form name="redirect"> <input type="radio" name="choose" onchange="return call()">yahoo</input> <input type="radio" name="choose" onchange="return call()">google</input> </form> Now write the script in head section as follows <script type="text/javascript"> function call() { for(var i=0;i<document.redirect.length;i++) { if(document.redirect.choose[i].checked) { role=document.redirect.choose[i].value; } } if(role=="yahoo") { window.open('http://www.yahoo.com','_self'); } else { window.open('http://www.google.com','_self'); } return true; } </script> PHP: This was found from http://s2sgateway.com/jsp/linking-two-or-more-pages-from-radio-button-using-javascript/ and i also found a similar tutorial http://www.mountaindragon.com/html/redirectjs2.htm but it didn't use radio buttons
thanks for your reply, Is there any simple php script? I require it for multiple webpages! and also require to open the web page in same window or new window using radio button.
Without adding a submit button for the form etc, you cannot process the radio buttons with PHP. If you wish to open them into a new window rather than the parent window, change the _self to _blank . If you want to put it into all pages, just simply add the javascript part into the head on all your pages. If your sites are PHP, you can easily make this into a file, and use an include.
to simplify for multiple urls do like Grit says with the include but have urls stored as variables so you don't have to have separate code for each url
You could always fake it with an image of a radio button that changes when clicked through css. Then you can just add as many urls as you want.