need help with drop down

M

max007

is there a way to create a dependent drop list form another drop down list
just like in excel?

and

if there is any way to calculate the results that i have?
 
T

Trevor Lawrence

max007 said:
is there a way to create a dependent drop list form another drop down list
just like in excel?

and

if there is any way to calculate the results that i have?

An example below from The JavaScript Source

To calculate something from what is selected, you would need to use more
JavaScript


<html>
<head>
<!-- Paste this code into an external JavaScript file named:
ropdownBox.js -->

<script type="text/javascript">
/* This script and many more are available free online at
The JavaScript Source :: http://javascript.internet.com
Created by: Christian Heilmann :: http://www.icant.co.uk/ */

function populate(o) {
d=document.getElementById('de');
if(!d) return;

var mitems=new Array();
mitems['Choose']=[''];
mitems['Salads']=['Select Item','Tuna Salad','Cesar Salad','Green
Salad','Prawn Salad'];
mitems['Main Courses']=['Select Item','Filet
Mignon','Porterhouse','Flank','T-Bone'];
mitems['Drinks']=['Select Item','Milkshake','Soda','Mixed Drink','Juice'];
mitems['Desserts']=['Select Item','Ice Cream','Fresh Fruit','Pie'];
mitems['Snacks']=['Select Item','Brownies','Cookies','Potato Chips'];

d.options.length=0;
cur=mitems[o.options[o.selectedIndex].value];
if(!cur) return;

d.options.length=cur.length;
for(var i=0;i<cur.length;i++) {
d.options.text=cur;
d.options.value=cur;
}
}
</script>

<!--
<script type="text/javascript" src="dropdownBox.js"></script> -->
</head>

<body>
<form action="" method="get">

<label for="or">Our menu:</label>
<select name="or" id="or" onchange="populate(this)">
<option value="Choose">Select from the Menu</option>
<option value="Salads">Salads</option>
<option value="Main Courses">Main Courses</option>
<option value="Drinks">Drinks</option>
<option value="Deserts">Deserts</option>
<option value="Snacks">Snacks</option>
</select>

<label for="de">Select:</label>
<select name="de" id="de"><option>Menu Option</option></select>
<input type="submit" value="Show me" />

</form>

<p><div align="center">
<font face="arial, helvetica" size"-2">Free JavaScripts provided<br>
by <a href="http://javascriptsource.com">The JavaScript Source</a></font>
</div><p>
</body>
</html>
 
S

Stefan B Rusynko

Search for chained or dynamic form fields
- an example is at http://www.dynamicdrive.com/dynamicindex16/chainedselects/index.htm
- or look here http://irt.org/script/form.htm#4


--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
_____________________________________________


is there a way to create a dependent drop list form another drop down list
just like in excel?

and

if there is any way to calculate the results that i have?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top