0

Hi
The below script does the job I am looking for
I am not to sure how to make the drop down dependant
ex ; Val 1 in box one return Val1 in Box 2 etc..

any idea someone

Sydney

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
<script type="text/javascript">
  // hard-coded inside the function.
  function populate() {
    var sel1 = document.getElementById("list1")
    var sel2 = document.getElementById("list2")
    var sel3 = document.getElementById("list3")
    var sel4 = document.getElementById("list4")
    var sel5 = document.getElementById("list5")
    var result = new Array()
    if (sel1.options[sel1.selectedIndex].value!="?") {
      result.push(sel1.options[sel1.selectedIndex].value)
    }
    if (sel2.options[sel2.selectedIndex].value!="?") {
      result.push(sel2.options[sel2.selectedIndex].value)
    }
    if (sel3.options[sel3.selectedIndex].value!="?") {
      result.push(sel3.options[sel3.selectedIndex].value)
    }
    if (sel4.options[sel4.selectedIndex].value!="?") {
      result.push(sel4.options[sel4.selectedIndex].value)
    }
    if (sel5.options[sel5.selectedIndex].value!="?") {
      result.push(sel5.options[sel5.selectedIndex].value)
    }

    // populate the selected value into text boxes
    for (var i=0; i<result.length; i++) {
      document.getElementById("box"+(i+1)).value = result[i]
    }
  }
</script>
</head>

<body>
Selection 1: <select id="list1">
  <option value="?">No Seletion</option>
  <option value="list1Val1">val1</option>
  <option value="list1Val2">val2</option>
  <option value="list1Val3">Val3</option>
  <option value="list1Val4">Val4</option>
</select>
<br />
Selection 2: <select id="list2">
  <option value="?">No Selection</option>
  <option value="list2Val1">Val1</option>
  <option value="list2Val2">Val2</option>
  <option value="list2Val3">Val3</option>
  <option value="list2Val4">Val4</option>
</select>
<br />
Selection 3: <select id="list3">
  <option value="?">No Selction</option>
  <option value="list3Val1">Val1</option>
  <option value="list3Val2">Val2</option>
  <option value="list3Val3">Val3</option>
  <option value="list3Val4">Val4</option>
</select>
<br />
Selection 4: <select id="list4">
  <option value="?">No select</option>
  <option value="list4Val1">Val1</option>
  <option value="list4Val2">Val2</option>
  <option value="list4Val3">Val3</option>
  <option value="list4Val4">Val4</option>
</select>
<br />
Selection 5: <select id="list5">
  <option value="?">No select</option>
  <option value="list5Val1">Val1</option>
  <option value="list5Val2">Val2</option>
  <option value="list5Val3">Val3</option>
  <option value="list5Val4">Val4</option>
</select>
<br /><br />
<input type="button" value="Finish" onclick="populate()">
<br /><br />
<input type="text" id="box1" size="10">&nbsp;&nbsp;
<input type="text" id="box2" size="10">&nbsp;&nbsp;
<input type="text" id="box3" size="10">&nbsp;&nbsp;
<input type="text" id="box4" size="10">&nbsp;&nbsp;
<input type="text" id="box5" size="10">
</body>
</html>

Edited by Sydney123: n/a

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by Sydney123
0

Hi,please make it more understandable. I am not getting your question.
What do you want to achieve?

Edited by Akash Saikia: n/a

0

Hi,
When List1Val1 is selected in drop down box1 it would return in drop down box 2 a choice of List1Val11, List1Val2, List1Val3
When List1Val2 is slected oin drop down box 1 it would return in drop down box 2 a chpoce of List1Val21, List1Val22, List1Va23

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.