I am using ASP Classic with VBScript on a web page. From a table I extract a recordset, the loop through it and assign the record ID to a value. When the user clicks on an article, it should post the record ID to another page, but I get a concatenated string like "1, 2 ,5, 7, 8" each number representing the record ID.
Here is the code portion where things go wrong:
<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
%>
Any help will be sincerely appreciated!
I think what you're after is a set of radio buttons. Unlike text fields, with a set of radio buttons all named the same thing, only the selected one's value will be returned.
<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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With