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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

why is this code not working

Status
Not open for further replies.

bells

MIS
Oct 5, 2001
51
0
0
CA
<%

dim i
dim x
dim y
dim z

x = Request.Form("mTrainee")
y= Request.Form("fTrainee")
z= cInt(x)+cInt(y)


For i = 1 to z

%>

<TR>

<TD>


<INPUT NAME=("lname"<% & i %> ) SIZE="20"></TD><TD><INPUT NAME=("organ"<% & i %> ) SIZE="20"></TD><TD><INPUT NAME=("profess"<% & i %>") SIZE="20"></TD><TD><INPUT NAME=("pNum"<% & i %> ) SIZE="20"></TD>



</TR>

<%

Next

%>

its purpose is to generate text boxes with names like
lname1, organ1...
lname2,organ2....
depending on what z is
it keeps telling me &i is the error. last time i used something like this to enter the value in the database that worked but this is not working any help is appreciated
 
& is to concatenated something. you should use <%= here:



<INPUT NAME=("lname"<%= i %> ) SIZE="20"></TD><TD><INPUT NAME=("organ"<%= i %> ) SIZE="20"></TD><TD><INPUT NAME=("profess"<%= i %>") SIZE="20"></TD><TD><INPUT NAME=("pNum"<%= i %> ) SIZE="20"></TD>





ttmug.gif
 
Well now i do not have any error
but for some reason it does not save the value of these
text boxes into the database.
is there anyway i for sure know how the name are created

because i can see the primary key is generated in access but
the value of these tables are not showing..

I tried
Response.Write Request.Form("lname1")
Response.Write Request.Form("lname2")

nothing is writing any reason???
it would actually be great that i know for sure
the names of the textboxes are as i wanted like lname1,lname2....
 
Use this to see what you receive from the page:

Code:
for each variable_name in request.form
 response.write variable_name & " = " &_
                variable_value & "<br>"
next
response.end

ttmug.gif
 
this works better:
Code:
for each variable_name in request.form
 response.write variable_name & " = " &_
       request.form(variable_name) & "<br>"
next
response.end

ttmug.gif
 
Well using the following code as suggested
x = Request.Form("mTrainee")
y= Request.Form("fTrainee")
z= cInt(x)+cInt(y)


For i = 1 to z

%>

<TR> <TD>

<INPUT NAME= ("lname"<% = i %> ) SIZE="20"></TD><TD><INPUT NAME=("org"<%= i %> ) SIZE="20"></TD><TD><INPUT NAME=("prof"<%= i %> ) SIZE="20"></TD><TD><INPUT NAME=("pNum"<%= i %> ) SIZE="20">
</TD>
</TR>

<%
Next
%>

Gives me
("lname"1
("lname"2
("lname"3 as the name of the text boxes what i want actually is lname1, lname2...without the quote an brackate
thank u again
 
hey. Actually, I think it should be

Code:
<INPUT NAME="lname<%=i%>" SIZE="20">

Also, I tend to like to just Response.Write the whole thing:
(I am assuming you are doing it in a loop)
Code:
<%Dim p
	p=10
	For i=0 to p
	Response.Write "<input name='blah" & i & "' size='20'>"
	Next%>

This way seems to be cleaner looking than having to break up all the asp tags.
 

Thank u very much
it is working fine now
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top