If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > <%Recset.Movenext%> won't work in JS Iteration. Please help :)

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-13-04, 11:37
Mirador Mirador is offline
Registered User
 
Join Date: Jan 2004
Location: Oslo
Posts: 45
<%Recset.Movenext%> won't work in JS Iteration. Please help :)

Hi there

Most of the code here is Javascript, but the problem-code is infact the ASP code in it..

i've tried to print out the value of postRs("postnr") and postRs("poststed") for each iteration , but it's not doing what should be done :
<%postRs.Movenext%>..

Is there another way to do what i'm trying to do ?

-----------------SQL QUERIES-----------------------
<%
Dim postRs
objCommand.CommandText = "SELECT postnr, poststed from POSTINFO"
set postRs = objCommand.Execute

'<finn antall poststed og nummer>
Dim ant
objCommand.CommandText = "SELECT count(postnr) from POSTINFO"
ant=objCommand.Execute
%>
---------END SQL QUERIES---------------------

--------------------JS WITH ASP-----------------
<script language=JavaScript>
var nrTab = new Array(<%=ant(0)%>);
var stedTab = new Array(<%=ant(0)%>);

var iCount = 0;

<%postRs.MoveFirst%>

while (iCount < <%=ant(0)%>)
{
nrTab[iCount] = '<%=postRs("postnr")%>';
stedTab[iCount] = '<%=postRs("poststed")%>';
<%postRs.MoveNext%>
iCount++;

}

alert(stedTab[iCount]);


</script>
__________________
Best regards
Mirador
Reply With Quote
  #2 (permalink)  
Old 10-13-04, 19:36
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
Well it kinda looks fine to be honest. My only question would be is this all the code. Or is you JS inside a loop for iterating through the recordset?? If not the code you are showing will only work for the first record and then ignore the others because there is no loop.
Reply With Quote
  #3 (permalink)  
Old 10-13-04, 20:02
Mirador Mirador is offline
Registered User
 
Join Date: Jan 2004
Location: Oslo
Posts: 45
Unhappy

Hey there, and thanx for the reply

Well.. it's all the code infact.. (except code for db connection and that..
I haven't made the code for displaying into a field and all that (front-end) but i have tried to :

1)
Run a --> alert('<%=postRs("postnr")%>'); just before the <%postRs.MoveNext%> to see if it loops, and it dont seem soo, cause it's returning the same value x number of times of posts in the database.

2)
Run a --> alert(stedTab[iCount]); to check for the same, but same happens.

The weird thing is though.. if i put the alert('<%=postRs("postnr")%>'); _BEFORE_ the MoveNext, it returns the _first_ post in the database, if i put it right _AFTER_ the MoveNext, it returns the _second_ post in the database.
This proves that there's _some_ kind of loop going on, but i cannot figure out why it stops (if first postnr is "110" it writes "110" for x number of posts in the db, if the second post is "114" it writes "114" for x number of posts..

I have altso checked that the asp-variable ant(0) is showing the correct amount of posts in the db.

Weird isn't it ?

Will be forever-happy-happy if anyone know what this bugger of a code can be
__________________
Best regards
Mirador
Reply With Quote
  #4 (permalink)  
Old 10-13-04, 20:20
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
if that is all the code then it is not weird at all.... try this...
Code:
-----------------SQL QUERIES-----------------------
<%
Dim postRs
objCommand.CommandText = "SELECT postnr, poststed from POSTINFO"
set postRs = objCommand.Execute

'<finn antall poststed og nummer>
Dim ant
objCommand.CommandText = "SELECT count(postnr) from POSTINFO"
ant=objCommand.Execute
%>
---------END SQL QUERIES---------------------

--------------------JS WITH ASP-----------------
<script language=JavaScript>
var nrTab = new Array(<%=ant(0)%>);
var stedTab = new Array(<%=ant(0)%>);

var iCount = 0;

<%
Do while not postRs.eof
%>
while (iCount < <%=ant(0)%>) 
{
nrTab[iCount] = '<%=postRs("postnr")%>';
stedTab[iCount] = '<%=postRs("poststed")%>';
<%postRs.MoveNext
Loop
%>
iCount++; 

} 

alert(stedTab[iCount]);

</script>
Note the do while and the loop statements....
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On