seetheworldsecond Posted July 21, 2011 Share Posted July 21, 2011 Hello phpfreak community, The issue I am having will probably be something very easy for most of you. My goal is to be able to have multiple radio buttons which when checked will determine which form auction to choose. As you can see in my code I currently do not have any radio buttons at the moment because each attempt I have failed miserably. <form action="/searching/index.php" method="POST"> <input type="text" name="search" class="searchbar"/> <input type="image" src="search.jpg" alt="Submit details" class="switch"/> </form> Below is the website I am trying to add this too. www.searchpopularthings.com Thanks for your help guys. Link to comment https://forums.phpfreaks.com/topic/242531-how-do-i-switch-a-form-action-with-a-radio-button/ Share on other sites More sharing options...
seetheworldsecond Posted July 22, 2011 Author Share Posted July 22, 2011 After too many hours of research online I found out the solution, in case anyone else needs help on this use this code below. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd"> <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <script type="text/javascript"> function usePage(frm,nm){ for (var i_tem = 0, bobs=frm.elements; i_tem < bobs.length; i_tem++) if(bobs[i_tem].name==nm&&bobs[i_tem].checked) frm.action=bobs[i_tem].value; } </script> </head> <body> <div> <form action="#" method="post" onsubmit="usePage(this, 'bob');"> <input type="radio" name="bob" value="regtku1.htm"> <input type="radio" name="bob" value="regtku2.htm"> <input type="radio" name="bob" value="regtku3.htm"> <input type="submit" value="Go"> </form> </div> </body> </html> Link to comment https://forums.phpfreaks.com/topic/242531-how-do-i-switch-a-form-action-with-a-radio-button/#findComment-1245986 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.