dynamically populate drop down menu option value problem

Discussion in 'ASP General' started by julian, Jul 26, 2003.

  1. julian

    julian Guest

    hi

    I was wondering if anyone can help me out on this....

    I have dynamcally populated a drop down menu with data from an access
    database using ASP. The values seem fine, however when i pass them to
    the next page (using form get method) the whitespaces in the values
    are ignored. For example with <option value=jim jones> then only "jim"
    gets passed to the next page not "jim jones". I have viewed the source
    created on the dynamic page and the values are populated fine, but
    passing to the next page seems to be problematic...

    My code....

    <form name="search2"
    <%if registered then%>
    action="xresults1.asp"
    <%else%>
    action="xresults.asp"
    <%end if%>
    method="get">

    <%

    if isempty(Application("Recordset2strcacheUsers")) then

    Set db = Server.CreateObject("ADODB.Connection")
    db.Open MM_database2_STRING

    Set Recordset2 = db.Execute("SELECT DISTINCT Field2 FROM IaxData WHERE
    Field19 = '1'")

    '*******populate drop down list********

    Recordset2str = "<SELECT NAME=subject><OPTION
    value=choose>Subject</OPTION>"
    while not Recordset2.eof
    Recordset2str = Recordset2str & "<OPTION VALUE=" &
    Recordset2.fields("Field2") & ">" & Recordset2.fields("Field2") &
    "</OPTION>"
    Recordset2.moveNext
    wend

    Recordset2str = Recordset2str & "</SELECT>"
    Response.write("<br>from database<br>" & Recordset2str)

    '********write to cache***********
    Application.lock()
    Application("Recordset2strcacheUsers") = Recordset2str
    Application.unlock()

    db.Close
    Set db = Nothing

    else
    ' Write from cache
    Response.write("<BR>from cache<BR>" & Application
    ("Recordset2strcacheUsers"))

    end if
    %>

    </form>
    julian, Jul 26, 2003
    #1
    1. Advertising

  2. julian

    Ray at Guest

    Enclose your values in quotes.

    Recordset2str = Recordset2str & "<OPTION VALUE=""" &
    Recordset2.fields("Field2") & """>" & Recordset2.fields("Field2") &
    "</OPTION>"

    Ray at home

    --
    Will trade ASP help for SQL Server help


    "julian" <> wrote in message
    news:...
    > hi
    >
    > I was wondering if anyone can help me out on this....
    >
    > I have dynamcally populated a drop down menu with data from an access
    > database using ASP. The values seem fine, however when i pass them to
    > the next page (using form get method) the whitespaces in the values
    > are ignored. For example with <option value=jim jones> then only "jim"
    > gets passed to the next page not "jim jones". I have viewed the source
    > created on the dynamic page and the values are populated fine, but
    > passing to the next page seems to be problematic...
    >
    > My code....
    >
    > <form name="search2"
    > <%if registered then%>
    > action="xresults1.asp"
    > <%else%>
    > action="xresults.asp"
    > <%end if%>
    > method="get">
    >
    > <%
    >
    > if isempty(Application("Recordset2strcacheUsers")) then
    >
    > Set db = Server.CreateObject("ADODB.Connection")
    > db.Open MM_database2_STRING
    >
    > Set Recordset2 = db.Execute("SELECT DISTINCT Field2 FROM IaxData WHERE
    > Field19 = '1'")
    >
    > '*******populate drop down list********
    >
    > Recordset2str = "<SELECT NAME=subject><OPTION
    > value=choose>Subject</OPTION>"
    > while not Recordset2.eof
    > Recordset2str = Recordset2str & "<OPTION VALUE=" &
    > Recordset2.fields("Field2") & ">" & Recordset2.fields("Field2") &
    > "</OPTION>"
    > Recordset2.moveNext
    > wend
    >
    > Recordset2str = Recordset2str & "</SELECT>"
    > Response.write("<br>from database<br>" & Recordset2str)
    >
    > '********write to cache***********
    > Application.lock()
    > Application("Recordset2strcacheUsers") = Recordset2str
    > Application.unlock()
    >
    > db.Close
    > Set db = Nothing
    >
    > else
    > ' Write from cache
    > Response.write("<BR>from cache<BR>" & Application
    > ("Recordset2strcacheUsers"))
    >
    > end if
    > %>
    >
    > </form>
    Ray at, Jul 26, 2003
    #2
    1. Advertising

  3. julian

    julian Guest

    thx ray.
    always boils down to punctuation!


    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    julian, Jul 26, 2003
    #3
  4. you need to enclose the value with ""... i.e.

    > Recordset2str = "<SELECT NAME=subject><OPTION
    > value=choose>Subject</OPTION>"
    > while not Recordset2.eof
    > Recordset2str = Recordset2str & "<OPTION VALUE=""" &
    > Recordset2.fields("Field2") & """>" & Recordset2.fields("Field2") &
    > "</OPTION>"
    > Recordset2.moveNext
    > wend
    >
    > Recordset2str = Recordset2str & "</SELECT>"
    > Response.write("<br>from database<br>" & Recordset2str)


    "julian" <> wrote in message
    news:...
    > hi
    >
    > I was wondering if anyone can help me out on this....
    >
    > I have dynamcally populated a drop down menu with data from an access
    > database using ASP. The values seem fine, however when i pass them to
    > the next page (using form get method) the whitespaces in the values
    > are ignored. For example with <option value=jim jones> then only "jim"
    > gets passed to the next page not "jim jones". I have viewed the source
    > created on the dynamic page and the values are populated fine, but
    > passing to the next page seems to be problematic...
    >
    > My code....
    >
    > <form name="search2"
    > <%if registered then%>
    > action="xresults1.asp"
    > <%else%>
    > action="xresults.asp"
    > <%end if%>
    > method="get">
    >
    > <%
    >
    > if isempty(Application("Recordset2strcacheUsers")) then
    >
    > Set db = Server.CreateObject("ADODB.Connection")
    > db.Open MM_database2_STRING
    >
    > Set Recordset2 = db.Execute("SELECT DISTINCT Field2 FROM IaxData WHERE
    > Field19 = '1'")
    >
    > '*******populate drop down list********
    >
    > Recordset2str = "<SELECT NAME=subject><OPTION
    > value=choose>Subject</OPTION>"
    > while not Recordset2.eof
    > Recordset2str = Recordset2str & "<OPTION VALUE=" &
    > Recordset2.fields("Field2") & ">" & Recordset2.fields("Field2") &
    > "</OPTION>"
    > Recordset2.moveNext
    > wend
    >
    > Recordset2str = Recordset2str & "</SELECT>"
    > Response.write("<br>from database<br>" & Recordset2str)
    >
    > '********write to cache***********
    > Application.lock()
    > Application("Recordset2strcacheUsers") = Recordset2str
    > Application.unlock()
    >
    > db.Close
    > Set db = Nothing
    >
    > else
    > ' Write from cache
    > Response.write("<BR>from cache<BR>" & Application
    > ("Recordset2strcacheUsers"))
    >
    > end if
    > %>
    >
    > </form>
    Lord Unspecified, Nov 5, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Laura K

    drop down menu looses initial option

    Laura K, Apr 10, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    1,124
    OHM \( One Handed Man \)
    Apr 11, 2006
  2. weiwei
    Replies:
    0
    Views:
    1,002
    weiwei
    Jan 5, 2007
  3. msimmons
    Replies:
    0
    Views:
    460
    msimmons
    Jul 16, 2009
  4. Greg Scharlemann

    Dynamic populate drop down menu

    Greg Scharlemann, Dec 9, 2003, in forum: Javascript
    Replies:
    4
    Views:
    134
    Thomas 'PointedEars' Lahn
    Dec 12, 2003
  5. bwv871

    populate drop down menu

    bwv871, Feb 15, 2004, in forum: Javascript
    Replies:
    0
    Views:
    85
    bwv871
    Feb 15, 2004
Loading...

Share This Page