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

How to do looping with array..

Status
Not open for further replies.

choohean

Technical User
Jan 15, 2002
57
MY
I've tried to do something like below so that I can do the insert procedure to save a few sets of data into the database from a multirow table... Can anyone here please help to have a look what's wrong it it?!

dim number, counter

counter = 0

number=Request.Form("count")

Do until counter = number
counter = counter + 1

yr = Request.Form("yr_"&counter&"")

Response.Write(yr)

Loop
 
Try this:

Code:
dim number, counter

counter = 0

number=Request.Form("count")

Do until counter = number
  counter = counter + 1
      
    yr = Request.Form("yr_"&counter)
    
    Response.Write(yr)

Loop
This is not a bug - it's an undocumented feature...
;-)
 
I've tried but come out with an error...

Active Server Pages, ASP 0113 (0x80004005)
The maximum amount of time for a script to execute was exceeded. You can change this limit by specifying a new value for the property Server.ScriptTimeout or by changing the value in the IIS administration tools.
 
Sounds like an infinite loop...
What exactly are you trying to accomplish?

Do you have a form calling this?! This is not a bug - it's an undocumented feature...
;-)
 
Ya... I got a form to call this function...Can you help me to have a look on the form....

this is my form!

<head>
<script LANGUAGE=&quot;javascript&quot;>
<!--

var totalTableRow = 1; // NUMBER OF DE TABLE ROWS

function addTableRow(tableName)
{
totalTableRow = totalTableRow + 1
var newRow;
var newCell;
var currentRow;

currentRow = totalTableRow

newRow = tableName.insertRow();

newCell = newRow.insertCell();
newCell.innerHTML = &quot;<SELECT id=yr_&quot; + currentRow + &quot; name=yr_&quot; + currentRow + &quot;><OPTION value=2002>2002</OPTION><OPTION value=2003>2003</OPTION><OPTION value=2004>2004</OPTION></SELECT>&quot;

newCell = newRow.insertCell();
newCell.innerHTML = &quot;<INPUT type='text' id=fm_&quot; + currentRow + &quot; name=fm_&quot; + currentRow + &quot;>&quot;;

newCell = newRow.insertCell();
newCell.innerHTML = &quot;<INPUT type='text' id=sq_&quot; + currentRow + &quot; name=sq_&quot; + currentRow + &quot;>&quot;;

document.form1.count.value = currentRow

}

</script>


</head>
<body>

<form name=&quot;form1&quot; method=&quot;post&quot; action=&quot;try6.asp&quot;>
<p> </P>
<table id=&quot;deTable&quot; name=&quot;teTable&quot; border=&quot;1&quot; width=&quot;100%&quot;>
<tr>
<td>Year</TD>
<td>Make</TD>
<td>Model</TD></TR>
<tr>
<td>
<select id=&quot;yr_1&quot; name=&quot;yr_1&quot;>
<option value=&quot;2002&quot; selected>2002</OPTION>
<option value=&quot;2003&quot;>2003</OPTION>
<option value=&quot;2004&quot;>2004</OPTION></SELECT> </TD>
<td><input id=&quot;mk_1&quot; name=&quot;mk_1&quot;></TD>
<td><input id=&quot;dl_1&quot; name=&quot;dl_1&quot;></TD></TR></TABLE>
<hr>
Total Entry(ies):
<INPUT id=&quot;count&quot; name=&quot;count&quot; value=&quot;1&quot; style=&quot;HEIGHT: 22px; WIDTH: 40px&quot;><br>
<input type=&quot;button&quot; value=&quot;Add Row&quot; id=&quot;badd&quot; name=&quot;badd&quot; onclick=&quot;addTableRow(deTable);&quot;>

<input type=&quot;submit&quot; value=&quot;Submit&quot; id=&quot;submit1&quot; name=&quot;submit1&quot;>
</FORM>

</body>
</html>
 
Your problem is in these two lines of code:
Code:
number=Request.Form(&quot;count&quot;)

Do until counter = number

counter and number never get equal, as the one is a integer and the other a string...

try this instead:
Code:
number=CInt(Request.Form(&quot;count&quot;))

Do until counter = number
This is not a bug - it's an undocumented feature...
;-)
 
Thanks...It work....
Really thanks a lot for helping me...
You are so kind...

regards, eddy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top