Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Looping question

Status
Not open for further replies.

PushCode

Programmer
Dec 17, 2003
573
US
I'm not sure how to best explain this, but I'll give it a shot. I have an edit form that among other fields, will show eight <input type="file"..> fields. I want to loop through my query and if an image already exists that corresponds to one of these file fields, I want to display the image next to it. Then for those that do not have an image associated with them, just display the input field by itself. So no matter what, there are always eight fields displayed. How do I make this loop continue until it outputs eight tolal times, even if the query returns less than eight records. I'm not sure how to handle this kind of loop. Here's what I have, but it only shows fields that do have an image associated with them.
Code:
<% Dim i
Dim finalE
i = 1
finalE = 8
	For i = 1 to finalE
		strImgName = qProd("img_name")
		If strImgName <> "" Then
		%>
			<br>
			Photo <%= i %>:
			<input type="file" size="50" name="File<%= i %>" /><img src='<%= strImgName %>' border="2" style="border-color:#CCCCCC">
		<%
		Else
		%>
			<br>
			Photo <%= i %>:
			<input type="file" size="50" name="File<%= i %>" />
		<%
		End If
		i = i + 1
		qProd.movenext
	Next
%>
 
Try this.
Dim i
Dim finalE
i = 1
finalE = 8
For i = 1 to finalE
strImgName = qProd("img_name")
If strImgName <> "" Then
%>
<br>
Photoy <%= i %>:
<input type="file" size="50" name="File<%= i %>" ID="File1"/><img src='<%= strImgName %>' border="2" style="border-color:#CCCCCC">
<%
Else
%>
<br>
Photon <%= i %>:
<input type="file" size="50" name="File<%= i %>" ID="File2"/>
<%
End If
'i = i + 1 ' COMMETED OUT
qProd.movenext
Next
 
That didn't work, but I figured out another way.

Thanks for the help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top