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
    Jan 2004
    Location
    Minnesota
    Posts
    86
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question drop down box Help (never mind just figured it out)

    Never mind, I just need to learn how to type
    (See answer below, just in case I'm not doing to correctly pls)



    ok here's the drop down box for my add screen (works fine)

    Code:
    <select name="Salutation" size="1">
       <option selected="selected">Salutation </option>
       <option value="Mr">Mr. </option>
       <option value="Ms">Ms. </option>
       <option value="Mrs">Mrs. </option>
    </select>
    And here's what I have on my modify screen (works fine)

    Code:
    <input type="text" name="Salutation" value="<%=(rsUnProc.Fields.Item("Salutation").Value)%>" size="32">
    what I want to do is have a drop down on my modify screen (vice an input box), but I'm not sure how to set up the select to have an initial value of <%=(rsUnProc.Fields.Item("Salutation").Value)%>


    Thanks in advance for any help
    J.C.
    To learn is a good thing and today I hope to learn something new!!

    ANSWER:
    (If this is not the correct way please let me know but it did work)

    Code:
    <select name="Salutation" size="1">
       <option selected="selected"><%=(rsUnProc.Fields.Item("Salutation").Value)%></option>
       <option value="Mr">Mr. </option>
       <option value="Ms">Ms. </option>
       <option value="Mrs">Mrs. </option>
    </select>
    Last edited by newkid; 08-18-2004 at 10:05 PM. Reason: Cause I cant type .... hehe

  • #2
    Senior Coder Morgoth's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada Remaining Brain Cells: 6
    Posts
    1,402
    Thanks
    2
    Thanked 1 Time in 1 Post
    Quote Originally Posted by newkid
    Code:
    <select name="Salutation" size="1">
       <option selected="selected"><%=(rsUnProc.Fields.Item("Salutation").Value)%></option>
       <option value="Mr">Mr. </option>
       <option value="Ms">Ms. </option>
       <option value="Mrs">Mrs. </option>
    </select>
    First off, I don't think selected="selected" is a real property. To make the box selected you just add the word "selected". Ex. <option value="blah" selected>

    It looks like you are a little confused, I think. In your modify screen it should allow you to change your answer in your drop down field, right, because you are modifing something for the database, correct?

    Here's what I would have done.
    Code:
    <%
    If rsUnProc.Fields.Item("Salutation").Value = "Mr" Then
      intSelected(0) = " selected"
    ElseIf rsUnProc.Fields.Item("Salutation").Value = "Ms" Then
      intSelected(1) = " selected"
    ElseIf rsUnProc.Fields.Item("Salutation").Value = "Mrs" Then
      intSelected(2) = " selected"
    End If
    %>
    <select name="Salutation" size="1">
       <option value="Mr"<%=intSelected(0)%>>Mr. </option>
       <option value="Ms"<%=intSelected(1)%>>Ms. </option>
       <option value="Mrs"<%=intSelected(2)%>>Mrs. </option>
    </select>
    This way, you will only have 3 options in the drop down menu. No two will look the same. You also forgot the value for the default selected, which is bad because if you submited the modified page, it wouldn't know what the Salutation is.

    Also, I give you a "Check Plus" on indenting!

  • #3
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Quote Originally Posted by Morgoth
    First off, I don't think selected="selected" is a real property. To make the box selected you just add the word "selected". Ex. <option value="blah" selected>
    In XHTML, all attributes must have a value. So selected="selected" is fine.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #4
    New Coder
    Join Date
    Jan 2004
    Location
    Minnesota
    Posts
    86
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks Morgoth, glenngv for the help

    J.C.
    To learn is a good thing and today I have learned something new!!


  •  

    Posting Permissions

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