atferraz
10-22-2003, 08: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>"
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>"