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!

Another loop question

Status
Not open for further replies.

jad73

Programmer
Apr 26, 2001
33
0
0
US
I have a form which asks the user the quantity of equipment that needs to be scanned. A loop begins and creates input boxes to the exact number the user enters.

Now I am trying to add the equipment into the database. Again I am using a loop for the quantity that the user chose. The problem is the serial and cam# need to be auto populated in the sql statement, like ser1, cam1 then ser2, cam2 and so forth. Here is the code I have now, can this be fixed?

I have a form which ask the user the quantity of equipment that needs to be scanned. A loop begins and creates input boxes to the exact number the user enters. Is there a way to name the boxes as they are being created during the loop so that i can in turn upload the information to my database?

Here is what I have:

for i = 1 to quantity
cam = request.form("cam" + i)
ser = request.form("ser" + i)
sql="INSERT INTO inventory ([sto_or_po],[date_rcv],[source],[location],[dealer_num],[manuf],[model_num],[condition],[serial_num],[cam_id]) VALUES "
sql=sql & "('" & sto & "','" & dater & "','" & source1 & "','" & location & "',"
sql=sql & "'" & dealer & "','" & manufacturer & "','" & model & "','" & condition & "','" & ser & "','" & cam & "')"
Set RS = oConn.Execute(sql)
set rs=nothing
next
 
Your code looks alright right now. A few things.
[ol][li]On an INSERT you don't need to "set rs= oConn.execute(sql)" just "oConn.execute(sql)"
[li]Make sure to verify the form before you call this page.
[li]A more user friendly approach to this whole thing is to allow the user to click a button and use javascript to create additional blanks in the form (using the DOM). It's much more elegant.
[li]We already worked on naming the boxes during the creation of the form - in another thread - dodn't we?
[/ol] Get the Best Answers! faq333-2924
"A witty saying proves nothing." - Voltaire
mikewolf@tst-us.com
 
I chenged my code as you said and I still get the same error.

Technical Information (for support personnel)

Error Type:
Microsoft VBScript runtime (0x800A000D)
Type mismatch: 'request'
/matrixtour/upload.asp, line 38


which line 38 is

cam = request.form("cam" + i)
 
Concatenation in VBScript is done with the & not the + sign. Try switching it and see what happens.

-Tarwn ________________________________________________________________________________
Want to get great answers to your Tek-Tips questions? Have a look at faq333-2924
 
Here's how to make a form where a user can input more values on the fly....

<script>
var idNum = 0;
function addInput(){
startForm = document.getElementById(&quot;myForm&quot;)
endForm = document.getElementById(&quot;subForm&quot;)
idNum ++

newLines = &quot;<span id='input&quot; + idNum +&quot;'><input name='input&quot; + idNum +&quot;'>&quot;
newLines += &quot;<input type=checkbox onClick='removeInput(&quot; + idNum + &quot;)'> Remove</span>&quot;

newnode=document.createElement(&quot;div&quot;);
newnode.innerHTML = newLines;
startForm.insertBefore(newnode, endForm);

}
function removeInput(inNum){
thisNode = document.getElementById(&quot;input&quot; + inNum)
thisNode.removeNode(true)
}

</script>
<body>
<form name=&quot;myForm&quot; id=&quot;myForm&quot;>
<input name=&quot;baseInput&quot;>

<br><input type=button value=&quot;Add field&quot; onClick=&quot;addInput()&quot; id=&quot;subForm&quot;>

</form>
</body> Get the Best Answers! faq333-2924
&quot;A witty saying proves nothing.&quot; - Voltaire
mikewolf@tst-us.com
 
Hi i think you just have a few syntax errors try the code below i changed your request.form part. hope it works

for i = 1 to quantity
cam = Request.Form(&quot;cam&quot;)(i))
ser = request.form(&quot;ser&quot;)(i))

sql=&quot;INSERT INTO inventory ([sto_or_po],[date_rcv],[source],[location],[dealer_num],[manuf],[model_num],[condition],[serial_num],[cam_id]) VALUES &quot;
sql=sql & &quot;('&quot; & sto & &quot;','&quot; & dater & &quot;','&quot; & source1 & &quot;','&quot; & location & &quot;',&quot;
sql=sql & &quot;'&quot; & dealer & &quot;','&quot; & manufacturer & &quot;','&quot; & model & &quot;','&quot; & condition & &quot;','&quot; & ser & &quot;','&quot; & cam & &quot;')&quot;
Set RS = oConn.Execute(sql)
next
set rs=nothing
 
Thanks Tarwn, thats what the problem was. I should have caught that :) Mwolf00, thats a good idea as well but wouldnt work in this situation. The user is actually receiving freight in our ware house usually around 128 or so pieces. by having the fields there all at once, he can just take his scanner and scan down through without touching the computer. Scanner actually tabs through each one once a number has been scanned in.

Thank you all for the help.

Jamie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top