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
    Regular Coder
    Join Date
    Aug 2002
    Location
    New York
    Posts
    152
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Need Help Scripting A Form Together

    Hi, I need help trying to tie together an idea of mine that involves multiple select boxes. It works basically identically to the way eBay allows sellers to choose a category for their item by narrowing down their item with multiple select boxes.

    My multiple select box looks like this, so far:

    <select multiple="multiple"><option>Option1</option><option>Option2</option></select>

    Ideally, there will be three of these. The trick I need help with is:

    a) making it so it's not really a *multiple* select box, but still looks like one. I want the user to see the options in the multi-line format as-is, but I only want them to be able to pick one at a time.
    b) when an option is selected, the subsequent multiple select box is enabled and loaded with the data of the selection (a subset). The data of the second box is determined by the selection in the first box. This box will not be enabled or populated until a selection is made.
    c) a way to obtain the information from a file stored on the directory. The info in this file will be the contents of the select box.

    Thanks for any assistance.

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    To have a multi-line select box, just set the size attribute. You don't have to set it to multiple if you want it to be single-select. There are a lot of double combo scripts out there on the Web. Google it.
    Code:
    <select size="5"><option>Option1</option><option>Option2</option></select>
    Glenn
    ____________________________________

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

  • #3
    Regular Coder
    Join Date
    Aug 2002
    Location
    New York
    Posts
    152
    Thanks
    12
    Thanked 0 Times in 0 Posts
    I see what you're saying about the size attribute, I really don't need the "multiple" thing in there. That makes it work perfectly, thank you.

    One of the results from the Google search you linked to was this one: http://simplythebest.net/scripts/DHT...script_63.html
    As you can see in that example, all of the select and option data is stored in the HEAD of the document, but is there a way to have it in a file instead?

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    You can put the script in an external .js file and link it in the script src.
    Code:
    <head>
    <script type="text/javascript" src="theScript.js"></script>
    </head>
    If the option items are dynamic and retrieved from the database or some other sources in the server, you can still link the file in the script src. You just need to set the content type to "text/javascript" in the server-side code and then output javascript. In the case of ASP, you do it like this:
    Code:
    <head>
    <script type="text/javascript" src="theScript.asp"></script>
    </head>
    theScript.asp:
    Code:
    <%
    Response.ContentType = "text/javascript"
    Response.Write "alert('test');"
    %>
    Glenn
    ____________________________________

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


  •  

    Posting Permissions

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