Results 1 to 7 of 7

Thread: Drop-down list problem

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2001
    Location
    Chennai, India
    Posts
    219

    Drop-down list problem

    Hi all,
    I have a drop-down listbox in my ASP page. I populate its content from a database. When the user chooses a value, it gets stored in the database only partially.
    For instance, if I choose 'ABC Company Ltd', it gets saved onyl as 'ABC'. Similarly, it gets saved only till the blankspace.
    Any guess why this is like this? I checked for ehe entire code, its all correct.
    Kindly help
    Om Nama Sivaya!!!

  2. #2
    chenko
    Guest
    in the value make sure you have " " or ' 'around the text


    Code:
    value="ABC Company Ltd"

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Feb 2001
    Location
    Chennai, India
    Posts
    219
    Hi Chenko,
    Here is the code which I use. Kindly help me

    <select name="brk_air">
    <%
    ' dim var_sel_brk_air
    rs.open "select * from schenker_master",cn,0,1
    rs.movefirst
    while not rs.EOF
    if rs("prospect_id") = var_ses_pros_id then
    var_sel_brk_air = rs("brk_air_name")
    end if
    rs.movenext
    wend
    rs.close

    rs.open "select * from schenker_broker_air",cn,0,1
    rs.movefirst
    while not rs.EOF
    if rs("brk_air_name") = var_sel_brk_air then
    response.write ("<option value=" & rs("brk_air_name") & " selected>" & rs("brk_air_name") & "</option>")
    else
    response.write ("<option value=" & rs("brk_air_name") & ">" & rs("brk_air_name") & "</option>")
    end if
    rs.movenext
    wend
    rs.close
    %>
    </select>
    </td>
    </tr>
    ..
    ..
    Om Nama Sivaya!!!

  4. #4
    chenko
    Guest
    Originally posted by Parasu Raman
    Hi Chenko,
    Here is the code which I use. Kindly help me

    <select name="brk_air">
    <%
    ' dim var_sel_brk_air
    rs.open "select * from schenker_master",cn,0,1
    rs.movefirst
    while not rs.EOF
    if rs("prospect_id") = var_ses_pros_id then
    var_sel_brk_air = rs("brk_air_name")
    end if
    rs.movenext
    wend
    rs.close

    rs.open "select * from schenker_broker_air",cn,0,1
    rs.movefirst
    while not rs.EOF
    if rs("brk_air_name") = var_sel_brk_air then
    response.write ("<option value='" & rs("brk_air_name") & "' selected>" & rs("brk_air_name") & "</option>")
    else
    response.write ("<option value='" & rs("brk_air_name") & "'>" & rs("brk_air_name") & "</option>")
    end if
    rs.movenext
    wend
    rs.close
    %>
    </select>
    </td>
    </tr>
    ..
    ..
    Ok, ive edited your code, I put ' ' in as you are using response.write, and also you needed a space before the "selected"

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Feb 2001
    Location
    Chennai, India
    Posts
    219
    Chenko,
    Thanx alot. It works perfect.
    Om Nama Sivaya!!!

  6. #6
    Frenzied Member monte96's Avatar
    Join Date
    Sep 2000
    Location
    Somewhere in AZ
    Posts
    1,379
    On a side note, why don't you use where clauses in your SQL statements. You should not load all the data then loop through it to find one record. Just ask the database for the record that matches your criteria.
    oOOo--oOOo
    __/\/\onte96
    oOOo--oOOo
    Senior Programmer/Analyst
    MCP
    [email protected]
    [email protected]


    Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Feb 2001
    Location
    Chennai, India
    Posts
    219
    Hi Monte96,
    Thats a good idea. I'll do that hereafterwards. I understand that it reduces the retrieval time

    Thanx again
    Om Nama Sivaya!!!

Posting Permissions

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



Click Here to Expand Forum to Full Width