我有一个表单(下面的代码),每次单击某个选项时,会出现一个按钮,其中会发送一个正确的值。单击它会将您带到异地处理表单。这部分工作正常。我需要的是其中一个选项,比如选项3可以为您提供单独的URL。我已经在使用onchange for selectbox了。有没有办法做多个onchange函数?可能通过选项ID定位?任何想法都将不胜感激。
<script>
function clicker(frm,value,button) {
frm.LinkId.value = value;
if (value != "") {
document.getElementById(button).style.display = "inline";
} else {
document.getElementById(button).style.display = "none";
}
}
</script>
<form name="PrePage" align="center" id="Prepage" method ="post" style="width:190px; text-align:center;" action= "https://Simplecheckout.authorize.net/payment/CatalogPayment.aspx">
<label for="selectbox" style="font-family: rockwell, helvetica, arial, sans-serif; font-size:1.5em"; width:190px; text-align:left;">This donation is for:</label>
<select style="margin:0 0 30px 0; width:180px;" size="1" name="selectbox" id="selectbox" onchange="clicker(document.PrePage,document.PrePage.selectbox.options[this.selectedIndex].value,'button');" >
<option selected value=""></option>
<option value="value1">Option 1</option>
<option value="value2">Option 2</option>
<option value="value3">Option 3</option>
<option value="value4">Option 4</option>
<option value="value5">Option 5</option>
</select>
<input type="hidden" name="LinkId" id="LinkId" value="" /><input id="button" style="display:none; margin:0 0 30px 0; text-align:center;" type="image" src="images/donate_button.gif" alt="Donate" />
</form>
答案 0 :(得分:1)
您可以检查值并相应地更改表单操作网址....例如:
function clicker(frm,value,button) {
if (value == 'value3')
frm.action = "http://www.google.com";
else
frm.action = "https://Simplecheckout.authorize.net/payment/CatalogPayment.aspx";
frm.LinkId.value = value;
if (value != "") {
document.getElementById(button).style.display = "inline";
} else {
document.getElementById(button).style.display = "none";
}
}
希望它有所帮助。