webForumDet fria alternativet

Desperat

3 svar · 180 visningar · startad av aleborg

aleborgMedlem sedan jan. 20013 341 inlägg
#1

Kan man inte köra två "Do until" i en loop?
I den här koden så körs inte "Do Until co.EOF" andra gången!


<% 
SqlCo="Select * From Countries Where Belongs=''"
Set cou=Conn.Execute(SqlCo)
Do Until cou.EOF
coSQL= "Select * From Countries Where Belongs="& cou("CountryID")
Set co=Conn.Execute(coSQL)
%>
<td width="25"><input type="radio" value="<%=cou("CountryID")%>" name="countrie"
<% 
Do Until co.EOF
If CInt(user("CountryBel"))=co("CountryID") then 
%>
 checked
<% 
End If
co.MoveNext
Loop
%>></td>
							<td width="263"><select name="CountryBel" size="1">
                <% Do Until co.EOF %>
                <option value="<%=co("CountryID")%>"<% If CInt(user("CountryBel"))=co("CountryID") then %> selected<% End If %>><%=co("CouName")%></option>
                <%
co.MoveNext
Loop
co.Close
Set co=Nothing
%>
              </select></td>
<%
cou.MoveNext
Loop
cou.Close
Set cou=Nothing
%>

Jag har tagit bort massor av HTML som vanligt för att ni lättare ska kunna läsa ut allt :)

------------------
Data-Doktorn
Min egen musik!
Mitt coverband

aleborgMedlem sedan jan. 20013 341 inlägg
#2

provade det här med:

<% 
SqlCo="Select * From Countries Where Belongs=''"
Set cou=Conn.Execute(SqlCo)
Do Until cou.EOF

coSQL= "Select * From Countries Where Belongs="& cou("CountryID")
Set co=Conn.Execute(coSQL)

Do Until co.EOF
If CInt(user("CountryBel"))=co("CountryID") then 
koll=" checked"
koll2=" selected"
End If
selec="<option value="& co("CountryID") &""& koll2 &">"& co("CouName") &"</option>"

co.MoveNext
Loop
%>
<td width="25"><input type="radio" value="<%=cou("CountryID")%>" name="countrie"<%=koll%>></td>
							<td width="263"><select name="CountryBel" size="1">
                <%=selec%>
              </select></td>
<%
co.Close
Set co=Nothing
cou.MoveNext
Loop
cou.Close
Set cou=Nothing
%>

men då får jag bara upp 1 land i varje select :(

------------------
Data-Doktorn
Min egen musik!
Mitt coverband

emissionMedlem sedan dec. 19996 721 inlägg
#3

Du kan inte köra två until co.eof på en gång, utan att köra en movefirst emellan.

Jag ser inte riktigt vad det åär du försöker göra, men om du verkligen vill loopa igenom samma sak flera gånger kan jag rekommendera att du gör en array med getrows.

aleborgMedlem sedan jan. 20013 341 inlägg
#4

nu kom du in på min starka sida inom ASP, array med getrows.......NOT :e

jag tror jag håller mig till movefirst :)

------------------
Data-Doktorn
Min egen musik!
Mitt coverband

134 ms totalt · 3 externa anrop · v20260731065814-full.cf67ef55
0 ms — hämta forumlista (cache)
0 ms — hämta statistik (cache)
129 ms — hämta tråd, inlägg och bilagor (db)