03. februar 2005 - 12:42Der er
5 kommentarer og 1 løsning
for next med et array
Hej
Jeg har et problem. I denne multiple select skriver den navnet 2 gange, sådan her: IT IT Web Design Web Design
Jeg kan ikke lige se hvad der kan være galt, her er koden:
<select name="specialty_id" class="border" multiple size="5"> <% SQLspecialty_id = "SELECT DISTINCT * FROM specialty ORDER BY specialty" Set RSspecialty_id = Conn.execute(SQLspecialty_id)
arr = Split(RSshow("specialty_id"),",")
Do While Not RSspecialty_id.EOF
for i = CInt(lbound(arr)) to CInt(ubound(arr)) if CInt(arr(i)) = CInt(RSspecialty_id("id")) then
SQLspecialty_specialty = "SELECT * FROM specialty WHERE id = '"&CInt(arr(i))&"'" Set RSspecialty_specialty = Conn.execute(SQLspecialty_specialty)
Den vil udskrive dem lige så mange gange som der er elementer i arrayet arr.
Du har i princippet to loop et på recordsetet som looget igennem for hver record og så har du en for sætning som for hvert element i arrayet udksirver en <option>. Det liger noget hvor du vil havde markeret de items som er valgt.
Prøv noget i stil med
<select name="specialty_id" class="border" multiple size="5"> <% SQLspecialty_id = "SELECT DISTINCT * FROM specialty ORDER BY specialty" Set RSspecialty_id = Conn.execute(SQLspecialty_id)
arr = Split(RSshow("specialty_id"),",")
Do While Not RSspecialty_id.EOF
for i = CInt(lbound(arr)) to CInt(ubound(arr)) fundet=false if CInt(arr(i)) = CInt(RSspecialty_id("id")) then fundet=true SQLspecialty_specialty = "SELECT * FROM specialty WHERE id = '"&CInt(arr(i))&"'" Set RSspecialty_specialty = Conn.execute(SQLspecialty_specialty)
fundet=false bliver vist sat en gang for sent det skal være lige før for sætningen så prøv sådan her:
<select name="specialty_id" class="border" multiple size="5"> <% SQLspecialty_id = "SELECT DISTINCT * FROM specialty ORDER BY specialty" Set RSspecialty_id = Conn.execute(SQLspecialty_id)
arr = Split(RSshow("specialty_id"),",")
Do While Not RSspecialty_id.EOF fundet=false for i = CInt(lbound(arr)) to CInt(ubound(arr)) if CInt(arr(i)) = CInt(RSspecialty_id("id")) then fundet=true SQLspecialty_specialty = "SELECT * FROM specialty WHERE id = '"&CInt(arr(i))&"'" Set RSspecialty_specialty = Conn.execute(SQLspecialty_specialty)
ok, jeg vil prøve at kikke efter det. Ellers vil jeg bare sige tusinde tak for hjælpen!
God aften :o)
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.