Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Aug 2003
    Posts
    82
    Thanks
    0
    Thanked 0 Times in 0 Posts

    select option <- Data problem

    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>"

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    Check out the Forum Search. It's the short path to getting great results from this forum.

  • #3
    New Coder
    Join Date
    Aug 2003
    Posts
    82
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Many thank Roy. At that hour anything goes wrong

  • #4
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You may as well make it valid XHTML...

    http://www.codingforums.com/showthre...threadid=27892


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •