【发布时间】:2015-08-20 18:39:23
【问题描述】:
如果选择了第二个选择选项,我完全不知道如何将开始标签更改为“method=post”。我正在为表单操作使用 Onchange,但也无法弄清楚如何更改 post 方法。 我最近的尝试是使用如下代码所示的 IF 语句,但同样,只有 1 个选项可以工作。
if(this.value){
$content .='<form action="/gsresults">';
}
else{
$content .='<form action="/imagesearch?go" method="post">';
}
$content .='<input type="text" name="q"/>
<input type="hidden" name="cx" value="partner-pub-xxxxxxxxxxx" />
<input type="hidden" name="cof" value="FORID:11" />
<input type="hidden" name="ie" value="UTF-8" />
<select onchange="this.form.action=this.value">
<option value="/gsresults" selected="selected">Google</option>
<option value="/imagesearch?go">Images</option>
</select>
<input type="submit" name="sa"/>
</form>';
感谢任何帮助/指点。
克里斯
【问题讨论】:
标签: html forms select if-statement onchange