我正在尝试将newbrand下拉列表中的值传递到下一页(addbrand.asp),但是,它不起作用,并且只是空白。任何人都可以指出我正确的方向如何解决这个问题?
<form class="form" method="post">
<table>
<%i = 0%>
<% for each brand in Brands %>
<tr><td><B><%=brand%></B></td>
<td><input type="button" class="btn btn-small" value="Delete" onclick="document.location='deletebrand.asp?brand=<%=brands(i)%>&client=<%=clientcno%>&id=<%=clientid%>'"></td></tr>
<%i = i + 1%>
<% next %>
<tr><td colspan=2><hr></td></tr>
<tr><td><B>Add:</B></td>
<td>
<select name="newbrand">
<option value=""></option>
<% for each brand in newbrands %>
<option value="<%=brand%>"><%=brand%></option>
<% next %>
</select>
<%
If Request.Form("newbrand") <> "" then
newbrand = Request.Form("newbrand")
End If
%>
<input type="button" class="btn btn-small" value="Add"
onclick="document.location='addbrand.asp?brand=<%=newbrand%>&client=<%=clientcno%>&id=<%=clientid%>'");">
</td></tr>
</table>
</form>
答案 0 :(得分:1)
如果按“添加”按钮,它应该将选定的'newbrand'发送到addbrand.asp?
现在传递服务器端值,您需要发送客户端值。将onclick更改为
document.location='addbrand.asp?brand=' + document.getElementsByName("newbrand")[0].options[document.getElementsByName("newbrand")[0].selectedIndex].value + '&client=...
由于内联Javascript,它有点乱。将一个ID分配给select元素会更容易,然后你可以使用document.getElementById,这样可以使它更简单:
document.location='addbrand.asp?brand=' + document.getElementById("newbrand").options[document.getElementById("newbrand").selectedIndex].value + '&client=...