ur code worked somehow... but let me know how should tha action page know that the loop has been run how many times. Any idea
Main Topics
Browse All TopicsLook at the following code:
<html>
<form name=book method=get action="action.asp">
<%
For i = 0 to 5
Response.Write "<input type=text name=fname size=15 maxlength=20>"
Next
%>
</form>
</html>
My question is that how to change the 'fname' field name n its value each time in a loop. What should be the change in the code so that all the 'fname' values could be easily passed via url('i.e., QueryString()') .
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
@
You need to keep a very clear idea about what is server-side and what is client-side.
The script above will output an HTML page with a form that has 6 fields, fname0, ... fname5.
The resulting HTML page will be something like this:
<html>
<form name=book method=get action="action.asp">
<input type=text name=fname0 size=15 maxlength=20>
<input type=text name=fname1 size=15 maxlength=20>
<input type=text name=fname2 size=15 maxlength=20>
<input type=text name=fname3 size=15 maxlength=20>
<input type=text name=fname4 size=15 maxlength=20>
<input type=text name=fname5 size=15 maxlength=20>
<input type=submit value=Submit>
</form>
</html>
(I've also inserted a submit button inside the form.)
When the user clicks submit the Key-Value pairs are appended to the URL and sent to the action.asp script.
The action.asp script copies these values into program variables:
<%
fname0=response.querystrin
...
fname5=response.querystrin
' and then process them
%>
@
Is your question now how to take EXISTING values already in the database and insert them as values in the HTML form fields so that visitors can see the existing value and change them if they want to.
If so, the basic method is:
<%
' Retrieve field data from table
sex=objRS("sex")
.... plus other fields
' Output HTML with existing value attached.
response.write "<input type=text name=sex value=" & sex & ">"
%>
' This would output to your HTML page either:
<input type=text name=sex value=male>
or
<input type=text name=sex value=female>
depending on the data in objRS("sex")
HTH
@
//-----First page:
<html>
<form name=book method=get action="action.asp">
<%
<input type='hidden' name='Cnt' value=5>
For i = 0 to Cnt
Response.Write "<input type='text' name='fname_" & CStr(i) & "'"
Next
%>
</form>
</html>
//-----action.asp
<%
Cnt = Request.Querystring("Cnt")
for i=1 to Cnt
fname = "fname_" & CStr(i)
fname = Request.Querystring("fname
Next
%>
Business Accounts
Answer for Membership
by: ActiveMediaPosted on 2003-03-16 at 14:39:30ID: 8147810
@
Try this:
<html>
<form name=book method=get action="action.asp">
<%
For i = 0 to 5
Response.Write "<input type=text name=fname" & CStr(i) & " size=15 maxlength=20>"
Next
%>
</form>
</html>
HTH
@