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

I have a dilemma with a Loop

Status
Not open for further replies.

JrClown

Technical User
Oct 18, 2000
393
US
How would I go about inserting this variable into my Access DB?
Here's my code

<p>Field1  <%=myconnect(&quot;Field1&quot;)%> </p>
<p>Field2<%=myconnect(&quot;Field2&quot;)%></p>
<p>Field3<%=myconnect(&quot;Field3&quot;)%></p>
<p># of  packages <%=reqpkgs%></p>
<%
for incounter = 1 to reqpkgs
%>
<input name=&quot;pkg<%=(incounter)%>&quot; > <hr>&quot;
<%
next
%>
The variable is being taken from a previous form.
QUOTE OF THE DAY
Not to know if bad; not to wish to know is worse.
<%
Jr Clown
%>
 
No ideas? QUOTE OF THE DAY
Not to know if bad; not to wish to know is worse.
<%
Jr Clown
%>
 
could you ask your question more clearly, if that variable was submited by a form in a previous page, I Would think the proper syntax is

myvariable = Request.Form(&quot;thevariablenamefrompreviouspage&quot;)

then the variable 'myvariable' has the value that was sent over.

is this what you mean? Karl Blessing aka kb244{fastHACK}
kblogo.jpg
 
I hope this explains it better:

The original form contains:
Field1:
Field2:
Field3: Field4: Field5:
Items: -- > This is an input text box
The user would then input in the Items field a number (it could be whatever # they want from 1-199). Then, I'm displaying all the data entered in the form and looping the variable
<p>Field1 <%=myconnect(&quot;Field1&quot;)%> </p>
<p>Field2<%=myconnect(&quot;Field2&quot;)%></p>
<p>Field3<%=myconnect(&quot;Field3&quot;)%></p>
<p># of packages <%=reqpkgs%></p>
<%
for incounter = 1 to reqpkgs
%>
<input name=&quot;Items<%=(incounter)%>&quot; > <hr>&quot;
<%
next
%>
to create text fields where the user would fill in based on the NUMBER typed on the Items: box.

So, my original dilemma is. How do I insert all fields that display based on the varialbe into my Access DB??
I hope this is clear. Thanks in advance. QUOTE OF THE DAY
Not to know if bad; not to wish to know is worse.
<%
Jr Clown
%>
 
This reads better

I hope this explains it better:

The original form contains:
Field1:
Field2:
Field3: Field4: Field5:
Items: -- > This is an input text box
The user would then input in the Items field a number (it could be whatever # they want from 1-199). Then, I'm displaying all the data entered in the form and looping the variable
<p>Field1 <%=myconnect(&quot;Field1&quot;)%> </p>
<p>Field2<%=myconnect(&quot;Field2&quot;)%></p>
<p>Field3<%=myconnect(&quot;Field3&quot;)%></p>
<p># of packages <%=reqpkgs%></p>
<%
for incounter = 1 to reqpkgs
%>
<input name=&quot;Items<%=(incounter)%>&quot; > <hr>&quot;
<%
next
%>
to create text fields where the user would fill in based on the NUMBER typed on the Items: box.

So, my original dilemma is. How do I insert all fields that display based on the varialbe into my Access DB??
I hope this is clear. Thanks in advance. QUOTE OF THE DAY
Not to know if bad; not to wish to know is worse.
<%
Jr Clown
%>
 
So basically, you will have some number of text fields with names, Items1, Items2, Items3, ... , Itemsn

Where n is some number between 1 and 199, right?

And you want to know how to insert those values into the database, yes???

Well, you would first need to read the value, 'reqpkgs' into a hidden form variable so that you could reference it when it's time to do the insert -- so you'll know how many input fields there are --

<input type=hidden name=numOfInputs value=<%=reqpkgs%>>

Then, I'm guessing the user is going to hit &quot;Submit&quot;, and then you need a script to go through and get all the values ---

<%
dim numOfInputs, i, elementName
numOfInputs = request.form(&quot;numOfInputs&quot;)
for i = 1 to numOfInputs
elementName = &quot;Items&quot; & i
rs.addnew
rs(&quot;theFieldName&quot;) = request.form(elementName)
rs.update
next
%>

Is that what you were looking for, or am I off the mark?

:)
Paul Prewett
 
I will look at it first thing in the morning link9. I think you're on to something here. QUOTE OF THE DAY
Not to know if bad; not to wish to know is worse.
<%
Jr Clown
%>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top