【问题标题】:change form action with radio buttons使用单选按钮更改表单操作
【发布时间】:2012-03-28 01:17:55
【问题描述】:

我想用单选按钮实现类似于 google 搜索的功能。根据选择的单选按钮,将更改搜索类型(搜索、图像、视频等)。

现在我有:

<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>

但是,单击单选框不会更改表单操作。有什么想法吗?

【问题讨论】:

    标签: html forms


    【解决方案1】:

    试试

    <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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-11-13
      • 2013-01-16
      • 1970-01-01
      • 2012-07-04
      • 1970-01-01
      • 2013-07-13
      • 2017-10-28
      • 1970-01-01
      相关资源
      最近更新 更多