PDA

View Full Version : Advice for editing a menu script



wright67uk
18 Apr 2011, 04:58 PM
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.


<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>

tivy
19 Apr 2011, 10:33 AM
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?