SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Jul 2010
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    List Box Issue, Selected results not showing

    I have several list boxes on a form. The users are able to come into the form and select multiple options in the list box. When they come back into the form to update their record the list boxes are only showing one of the options they selected. That's fine if they only select one item but most of the users select multiple items.

    Here is the code i am using for the list boxes, any help is greatly appreciated.


    Code:
    	<td>Analysis Type</td>
    <td><select name=ANALYSIS_TYPE size=4 multiple style="width:280px;height:380px;">
    		 <&#37;
    		sql = "SELECT APP_LIST_VALUE_DESC from  TICKER_APP_LIST_VALUE WHERE APP_LIST_ID = 4 ORDER BY APP_LIST_VALUE ASC  "	  
    		set rs = server.CreateObject("adodb.recordset")
    		rs.Open sql, conn
    		while not rs.eof 
    		Response.Write("<option value='"&rs(0)&"'")
    		if cstr(ANALYSIS_TYPE_UP)=cstr(rs(0)) then
    		 Response.Write (" selected ")
    		end if
    		Response.Write(">"&rs(0))
    		rs.movenext
    		wend
    		rs.close
    		set rs = nothing%>
    	</select>

  2. #2
    SitePoint Guru
    Join Date
    Jun 2007
    Posts
    691
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    looks like a syntax problem - look here for correct format

    http://www.w3schools.com/TAGS/att_option_selected.asp

  3. #3
    SitePoint Member
    Join Date
    Jul 2010
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm not seeing the syntax error you are referring to?

    The link you posted to a basic description of the <Select> tag.

  4. #4
    SitePoint Addict itHighway's Avatar
    Join Date
    Jan 2008
    Location
    GUJ
    Posts
    270
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OKay I understand what you mean and what you want. You need to use inStr function.
    Example:
    ANALYSIS_TYPE_UP = replace(ANALYSIS_TYPE_UP, ", ", ",") 'remove any spaces with comma

    - while loop

    txtRecordSetValue = replace(rs(0), ", ", ",") 'remove spaces with comma
    if inStr(ANALYSIS_TYPE_UP, txtRecordSetValue) > 0 then
    - Selected
    end if
    The key in the above is to remove spaces next to comma AND use inStr function.

  5. #5
    SitePoint Guru
    Join Date
    Jun 2007
    Posts
    691
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by jjsaw5 View Post
    I'm not seeing the syntax error you are referring to?

    The link you posted to a basic description of the <Select> tag.
    syntax should be:

    Response.Write ("selected=""selected""")

  6. #6
    SitePoint Member Kinamon's Avatar
    Join Date
    Aug 2010
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi
    Your post helped me a lot.
    And I have solved your problem...I don`t know if it is still relevant for you, but i`ll post an answer here.

    I replace a while loop to do until rs.EOF
    then I used a for loop

    I think that only a first value was displayed because of rs(0) , you index was never increasing
    <%
    dim j

    do until rs.EOF

    for each j in rs.Fields
    Response.Write("<option value='"&j.value&"'>"&j.value)
    .
    .
    .
    your code%>

    Hope this helps


Bookmarks

Posting Permissions

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