SitePoint Sponsor

User Tag List

Results 1 to 13 of 13
  1. #1
    SitePoint Member
    Join Date
    Jan 2011
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Lightbulb Help with drop down

    I have some code on a page. I know for a fact that all the variables are pulling the correct information from the recordsets, because I did some basic response.write to see if they were showing up... however, when the drop down is populated, they are not pulling the "selected" up... let me know if anyone can help. It may be due to the Loops that I have...just not sure how to fix it. thanks

    <%
    While ((Repeat3__numRows <> 0) AND (NOT rsFOOD.EOF))
    %>
    <%
    Dim subtotal
    subtotal=FormatNumber(rsFOOD("ITEMPrice"),2)*FormatNumber(rsFOOD("ITEMQuantity"),2)%>
    <tr>
    <td class="action_view"><select name="INVItem<%=rsFOOD("ITEMID")%>" id="INVItem<%=rsFOOD("ITEMID")%>">
    <% Do While Not rsFOOD2.EOF%>
    <% Dim SelectValue
    SelectValue=rsFOOD("ITEMINVID")
    %>
    <option value="<%=rsFOOD2("FOODID")%>" <%If SelectValue=rsFOOD2("FOODID") Then%>selected<%End If%>><%=rsFOOD2("FOODName")%></option>
    <%rsFOOD2.MoveNext%>
    <%Loop%>
    <%rsFOOD2.Requery%>
    </select></td>

  2. #2
    SitePoint Guru
    Join Date
    Jun 2007
    Posts
    690
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you may want to add some spaces around the word "selected" like

    ...Then%> selected <%End ....

  3. #3
    SitePoint Member
    Join Date
    Jan 2011
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Good thought, i tried this, but hasn't worked....Thanks.

  4. #4
    SitePoint Wizard bronze trophy
    Join Date
    Oct 2001
    Location
    Vancouver BC Canada
    Posts
    2,032
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    <%If SelectValue=rsFOOD2("FOODID") Then%>selected = "selected"<%End If%>
    Andrew Wasson | www.lunadesign.org
    Principal / Internet Development

  5. #5
    SitePoint Member
    Join Date
    Jan 2011
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Tried this as well, but no luck.. I think it has to do with the double loop happening, but can't figure out why! Keep them coming and I will keep trying. Thanks

  6. #6
    SitePoint Wizard bronze trophy
    Join Date
    Oct 2001
    Location
    Vancouver BC Canada
    Posts
    2,032
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    Well I just noticed that you are dimensioning your selectvalue variable inside the second loop which should actually throw an error. You should move the dim part outside of the loops and if you can assign the value to it above the loops that would be good as well but might not be possible.

    <%
    Dim SelectValue
    SelectValue=rsFOOD("ITEMINVID")
    %>

    What does the HTML output of the select list look like? Are you getting any occurrences of selected="selected"?
    Andrew Wasson | www.lunadesign.org
    Principal / Internet Development

  7. #7
    SitePoint Member
    Join Date
    Jan 2011
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Now errors are thrown, and the select value is working inside the loop, because I have set it to be written out above each Dropdown, and it shows up. I am not getting any selects to work properly...
    Thanks

  8. #8
    SitePoint Wizard bronze trophy
    Join Date
    Oct 2001
    Location
    Vancouver BC Canada
    Posts
    2,032
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    What does the html for your list look like? I wonder if you are seeing select=selected at all or multiple times.
    Andrew Wasson | www.lunadesign.org
    Principal / Internet Development

  9. #9
    SitePoint Member
    Join Date
    Jan 2011
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No selected shows up anywhere. Everything else works 100%, I am still in testing mode and working on other aspects of the form and page, and it is working 100%. All variables are pulling correctly. I even have the variables being used to name certain parts of the forms, and they are pulling properly after every loop, that is why this is bugging me with it.
    thanks

  10. #10
    SitePoint Guru
    Join Date
    Jun 2007
    Posts
    690
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you also have to verify not only that the two values look the same on the screen but that they are also the same type programmatically.


    sometimes a number comes through as a string when you expect it to be an integer

  11. #11
    SitePoint Member
    Join Date
    Jan 2011
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    As you typed that reply, I just figured that out!! It was a text field compared to an integer field, a simple CInt(variable) fixed it!
    Thanks

  12. #12
    SitePoint Wizard bronze trophy
    Join Date
    Oct 2001
    Location
    Vancouver BC Canada
    Posts
    2,032
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    Oh, that'll do it... It doesn't happen very often, probably because ASP is so loosely typed but every now and again I do the same thing
    Andrew Wasson | www.lunadesign.org
    Principal / Internet Development

  13. #13
    SitePoint Guru
    Join Date
    Jun 2007
    Posts
    690
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by barkerx5 View Post
    As you typed that reply, I just figured that out!! It was a text field compared to an integer field, a simple CInt(variable) fixed it!
    Thanks
    great minds think alike


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
  •