...

View Full Version : select option <- Data problem



atferraz
10-22-2003, 09:00 PM
Hello,
Have this problem in getting the right option from drop box to show when I edit a DB row in my form.
Firs I get the options fields (2) from a table to a array. Then I ask de number of de row to search for on the DB and show it on the form.
In the middle of that process, I fill the select options from the array and on each iteration I test if that option match the correspondent DB option field. If it does, that option get the "selected" attribute witch should define it to show. But it doesn't


SQLstm="Select nfunc FROM xpto"
rs.Open SQLstm,Lig,1,2
Dim i, arrXpto(3)

rs.MoveFirst
for i=0 to 2 ' get codes from xpto
arrXpto(i)= rs("nfunc")
rs.MoveNext
Next
rs.close

SQLstm="Select * FROM users where nuser="&userNumber 'get specific row from users where the cod is inserted by user
rs.Open SQLstm,Lig,1,2
.....
Response.Write"<select Class='form' name='funcao' style='position:relative; left:0px;'>" ' drop box
for i=0 to 2 'put the array fields on de options
Response.Write "<option class='form' value='" &arrXpto(i,0)
if cInt(arrXpto(i,0)) = cInt(rs("nfuncao")) then ' if the code option match with the row option field then is selected
Response.Write"selected"
end if
Response.write "</option>"
Next
Response.Write"</select>"

Roy Sinclair
10-22-2003, 11:35 PM
Your code is writing incomplete html code, nowhere are you writing the ">" for the <option> tag. You also need to add a space before "selected" and you also need to put the closing quote mark on the value of that option.

atferraz
10-23-2003, 03:44 AM
Many thank Roy. At that hour anything goes wrong

raf
10-23-2003, 08:33 AM
You may as well make it valid XHTML...

http://www.codingforums.com/showthread.php?s=&threadid=27892



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum