Results 1 to 2 of 2

Thread: Advice for editing a menu script

  1. #1
    Join Date
    Oct 2009
    Posts
    11

    Advice for editing a menu script

    Hello, I have seen this script which gives me a menu setup that I have been looking to get hold of for ages. Would anybody be able to give some advice.
    When I select my options and click 'Value Selected' a pop up box pops up with the selected value. Rather than have a pop up box, how can I use a users selection and intergate the selection with standard form html?

    eg.
    <input type="text or radio?" name="selection" />
    <input type="submit" value="Submit" />

    I would like to use the menu, but to be able to store an end value.

    Code:
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <script type="text/javascript">
    function setOptions(chosen) {
    var selbox = document.myform.opttwo;
     
    selbox.options.length = 0;
    if (chosen == " ") {
      selbox.options[selbox.options.length] = new Option('Please select one of the options above first',' ');
     
    }
    if (chosen == "1") {
      selbox.options[selbox.options.length] = new
    Option('Indian','Indian');
      selbox.options[selbox.options.length] = new
    Option('Chinese','Chinese');
    }
    if (chosen == "2") {
      selbox.options[selbox.options.length] = new
    Option('Pizza','Pizza');
      selbox.options[selbox.options.length] = new
    Option('Kebab','Kebab');
    }
    if (chosen == "3") {
      selbox.options[selbox.options.length] = new
    Option('1 Star','1 Star');
      selbox.options[selbox.options.length] = new
    Option('2 Star ','2 Star');
      selbox.options[selbox.options.length] = new
    Option('3 Star','3 Star');
      selbox.options[selbox.options.length] = new
    Option('4 Star ','4 Star');
      selbox.options[selbox.options.length] = new
    Option('5 Star ','5 Star');
    }
    }
    </script>
    <title>Untitled Document</title>
    </head>
    
    <body>
    <form name="myform"><div align="center">
    <select name="optone" size="1"
    onchange="setOptions(document.myform.optone.options
    [document.myform.optone.selectedIndex].value);">
    <option value=" " selected="selected"> </option>
    <option value="1">Restaurants</option>
    <option value="2">Takeaways</option>
    <option value="3">Hotels</option>
    </select><br> <br>
    <select name="opttwo" size="1">
    <option value=" " selected="selected">Please select one of the options above first</option>
    </select>
    <input type="button" name="go" value="Value Selected"
    onclick="alert(document.myform.opttwo.options
    [document.myform.opttwo.selectedIndex].value);">
    </div></form>
    </body>
    </html>

  2. #2
    Join Date
    May 2010
    Location
    College Station, TX
    Posts
    216
    The script doesn't know what the end game is, so the scripter just wrote an alert box at the end assuming you would use the data for whatever it is you want to do. So that begs the question, what exactly do you want to do with the user input? Do you want to use that information on a different page or to modify the current page or what?
    All web designers hate the internet. If I spend all day making/updating/looking at websites, why the hell would I want to deal with it outside of work?

Similar Threads

  1. need script advice for website design
    By focuz in forum General Questions
    Replies: 0
    Last Post: 18 Mar 2008, 02:26 PM

Tags for this Thread

Posting Permissions

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