Change form action using radio buttons

I would like to implement something similar to google search using radio buttons. The type of search (search, images, video, etc.) will change depending on the selected radio button.

Now I have:

<div id ="searchtext">
 <form method="get" id ="searchbox" action="http://www.google.com/search"/>
 <input type="text" name="q" size="30" class="searchtext" maxlength="255" value="" />
 <input type="image" value="Search" class="searchbutton" src="images/searchbar/searchbutton.png"/> 

<br/>
</div>
<div id="radiosearch">
<input type="radio" name="radiosearch" onclick="document.searchbox.action='http://www.google.com/search?q=';" checked="checked"/> Web
<input type="radio" name="radiosearch" onclick="document.searchbox.action='http://images.google.com/images?q=';"/>Images
<input type="radio" name="radiosearch" onclick="document.searchbox.action='http://maps.google.com/maps?hl=en&amp;tab=wl?q=';"/>Maps
<input type="radio" name="radiosearch" onclick="document.searchbox.action='http://www.youtube.com/results?q=';"/>Youtube
<span class = "class1">
<a href ="" onclick="loadthepopup();" name ="radiosearch">Change Theme</a>
</span>
</div>

      

However, clicking on the radio window does not change the action of the form. Any ideas?

+3


source to share


1 answer


Try



<input type="radio" name="radiosearch" onclick="document.getElementById('searchbox').action='http://www.google.com/search?q=';" checked="checked"/> Web
<input type="radio" name="radiosearch" onclick="document.getElementById('searchbox').action='http://images.google.com/images?q=';"/>Images
<input type="radio" name="radiosearch" onclick="document.getElementById('searchbox').action='http://maps.google.com/maps?hl=en&amp;tab=wl?q=';"/>Maps
<input type="radio" name="radiosearch" onclick="document.getElementById('searchbox').action='http://www.youtube.com/results?q=';"/>Youtube

      

+13


source







All Articles