我在网页上使用带有VBScript的ASP Classic。从表中我提取一个记录集,循环通过它并将记录ID分配给一个值。当用户点击文章时,它应该将记录ID发布到另一个页面,但我得到一个串联的字符串,如“1,2,5,7,8”,每个数字代表记录ID。
以下是出现问题的代码部分:
<form action="restaurant.asp" method="post">
<%
Do Until rs.EOF
%>
<article class="img-item" onClick="submitTD()">
<h3 class="hidden"></h3>
<figure >
<span class="thumb-screen"></span>
<img src="<%response.Write(rs("restTopDealPic"))%>" alt="<%response.Write(rs("restTopDealTagLine"))%>"/>
<figcaption>
<strong>
<%response.Write(rs("restName"))%> <br> <%response.Write(rs("restTopDealTagLine"))%>
</strong>
<%response.Write(rs("restTopDealDesc"))%>
</figcaption>
</figure>
</article>
<input class="hidden" name="mainTableIDS" id="mainTableIDS" value="<%response.Write(rs("MainTableID"))%>"/>
<input type="submit" id="TDSubmit" />
<%
'Move to the next record (important!!)
rs.MoveNext
Loop
%>
</form>
<%
rs.close
%>
真诚地感谢任何帮助!
答案 0 :(得分:0)
我认为你所追求的是一组单选按钮。与文本字段不同,一组单选按钮的名称相同,只返回选定的值。
<form ...>
<%
Do Until rs.EOF
Response.Write "<article ...>" 'etc. etc. etc.
'... figure, span, img, figcaption ...
Response.Write "<input type='radio' name='IDs'" 'same name for all radio buttons
Response.Write " id='id" & rs("MainTableID") & "'" 'ids must be unique
Response.Write " value='" & rs("MainTableID") & "' />" 'only the selected value will be posted
'--- close figcaption, etc.
Response.Write "</article>"
rs.Movenext
Loop
Response.Write "<input type='submit' value='Submit' />"
%>
</form>