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

Code not working - Why?

Status
Not open for further replies.

Chopstik

Technical User
Oct 24, 2001
2,180
US
Below is my code to add new records and iterate through, incrementing for each iteration. Can someone point out why it's not incrementing (or working in general for that matter)? Thanks!


<FORM NAME=&quot;frmDetail&quot; ACTION=&quot;LDPurchOrd3.asp&quot; METHOD=&quot;POST&quot;>
<%
dim count, i, j

if len(Request.form(&quot;count&quot;)) then
count = cInt(count)
for i = 0 to count
if len(Request.Form(&quot;strCost&quot;) & i) then
Response.Write Request.Form(&quot;strVenItemCd&quot;) & i & &quot;<BR>&quot;
Response.Write Request.Form(&quot;strVenDesc&quot;) & i & &quot;<BR>&quot;
Response.Write Request.Form(&quot;strUnits&quot;) & i & &quot;<BR>&quot;
Response.Write Request.Form(&quot;strUM&quot;) & i & &quot;<BR>&quot;
Response.Write Request.Form(&quot;strCost&quot;) & i & &quot;<BR>&quot;
end if
next
count = count + 1
else
count = 0
end if

Response.Write &quot;<table WIDTH=750>&quot;
Response.Write &quot;<tr>&quot;
Response.Write &quot;<td WIDTH='150' ALIGN='center'><strong>Vendor Item Code</strong></td>&quot;
Response.Write &quot;<td WIDTH='150' ALIGN='center'><strong>Item Description</strong></td>&quot;
Response.Write &quot;<td WIDTH='150' ALIGN='center'><strong>Units</strong></td>&quot;
Response.Write &quot;<td WIDTH='150' ALIGN='center'><strong>Unit of Measure</strong></td>&quot;
Response.Write &quot;<td WIDTH='150' ALIGN='center'><strong>Cost</strong></td>&quot;
Response.Write &quot;</tr>&quot;
Response.Write &quot;<tr>&quot;
Response.Write &quot;<td><input TYPE='text' NAME='strVenItemCd'></td>&quot;
Response.Write &quot;<td><input TYPE='text' NAME='strItemDesc' MAXLENGTH='200'></td>&quot;
Response.Write &quot;<td><input TYPE='text' NAME='strUnits'></td>&quot;
Response.Write &quot;<td><input TYPE='text' NAME='strUM'></td>&quot;
Response.Write &quot;<td><input TYPE='text' NAME='strCost'></td>&quot;
Response.Write &quot;</tr>&quot;
Response.Write &quot;</table>&quot;

i = 0
while i < count
Response.Write Request.Form(&quot;strCost&quot;)
if len(Request.Form(&quot;strCost&quot;) & i) then
Response.Write &quot;<td><input TYPE='hidden' NAME='strVenItemCd&quot; & count & &quot;'></td>&quot;
Response.Write &quot;<td><input TYPE='hidden' NAME='strItemDesc&quot; & count & &quot;'></td>&quot;
Response.Write &quot;<td><input TYPE='hidden' NAME='strUnits&quot; & count & &quot;'></td>&quot;
Response.Write &quot;<td><input TYPE='hidden' NAME='strUM&quot; & count & &quot;'></td>&quot;
Response.Write &quot;<td><input TYPE='hidden' NAME='strCost&quot; & count & &quot;'></td>&quot;
end if
i = i + 1
wend
Response.Write &quot;<td><input TYPE='hidden' NAME='count'></td>&quot;
%>
<BR>
<INPUT TYPE=&quot;submit&quot; NAME=&quot;btnAdd&quot; VALUE=&quot;Add&quot;>   
<INPUT TYPE=&quot;submit&quot; NAME=&quot;btnDone&quot; VALUE=&quot;Done&quot;>
</FORM>
 
What are you checking here?

if len(Request.form(&quot;count&quot;)) then

If &quot;5&quot; then? If what?

One of the best ways to debug your asp app. is to response.write variables to the screen to see if you are getting what you think you should be getting.
 
I've been doing that up to this point. I just keep coming back with data that doesn't make sense. Wasn't sure if someone else might be able to point out whatever stupid errors I must be making. :)
 
I made a couple of adjustments but still cannot get the iteration and results to work correctly. I set the hidden fields to iterate using &quot;i&quot; instead of &quot;count&quot;, but not sure if I need to do the same for the the original entry boxes or not? Or if there are other things I'm missing here. Any thoughts?


i = 0
while i < count
Response.Write Request.Form(&quot;strCost&quot;)
if len(Request.Form(&quot;strCost&quot;) & i) then
Response.Write &quot;<td><input TYPE='hidden' NAME='strVenItemCd&quot; & i & &quot;'></td>&quot;
Response.Write &quot;<td><input TYPE='hidden' NAME='strItemDesc&quot; & i & &quot;'></td>&quot;
Response.Write &quot;<td><input TYPE='hidden' NAME='strUnits&quot; & i & &quot;'></td>&quot;
Response.Write &quot;<td><input TYPE='hidden' NAME='strUM&quot; & i & &quot;'></td>&quot;
Response.Write &quot;<td><input TYPE='hidden' NAME='strCost&quot; & i & &quot;'></td>&quot;
end if
i = i + 1
wend

Thanks for any help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top