davthewav
08-16-2007, 10:04 AM
hi to everyone!
just joned this site, so hope your all doing well.....
i'm wondering if anyone can help me out with this problem....i'm trying to get javascript running which would have a drop down menu in which i could pick from one of....say 20/30 options....i would then want one of those options to be placed into a text box....on the same page, then to pick another option from the drop down menu and this then would be placed into another text box....say just underneath the first text box.....the code that i have at the moment is this:
<html>
<head>
<title>chose a team</title>
<script type='text/javascript'>
function doIt(selNum)
{
var selObj = document.theForm['rank'+selNum];
var prevNum = selNum-1;
var prevSel = document.theForm['rank'+prevNum]
selObj.options.length = 0;
for (var i = 0; i < prevSel.length; i++)
{
if (! prevSel.options[i].selected)
{
newItem = selObj.options.length;
selObj.options[newItem] = new Option(prevSel.options[i].text,
prevSel.options[i].value);
}
else {
document.theForm['text'+(selNum-1)].value = prevSel.options[i].text;
}
}
}
</script>
</head>
<body>
<h1><center>Chose a Team</center></h1>
<p>The teams</p>
<form name='theForm'><br>
<center><select name='rank1'onchange="doIt(2)">
<option value='Arsenal'>Arsenal</option>
<option value="Aston Villa">Aston Villa</option>
<option value="Birmingham">Birmingham</option>
<option value="Bolton">Bolton</option>
<option value="Chelsea">Chelsea</option>
<option value="Derby">Derby</option>
<option value="Everton">Everton</option>
<option value="Fulham">Fulham</option>
<option value="Liverpool">Liverpool</option>
<option value="Manchester City">Manchester City</option>
<option value="Manchester Utd">Manchester Utd</option>
<option value="Middlesboro">Middlesboro</option>
<option value="end of selection">end of selection</option>
</select></center><br>
<input type="text" name="text1"/>
<center><select name='rank2' onchange="doIt(3)">
</select></center>
<input type="text" name="text2"/>
<center><select name='rank3' onchange="doIt(4)">
</select></center>
<input type="text" name="text3"/>
<center><select name='rank4'>
</select></center>
</form>
</body>
</html>
as you can see this code gives me other drop down menus.....which i want to get rid of......but i can't work out how to do this.
any help would be very welcome
thanks
dav
just joned this site, so hope your all doing well.....
i'm wondering if anyone can help me out with this problem....i'm trying to get javascript running which would have a drop down menu in which i could pick from one of....say 20/30 options....i would then want one of those options to be placed into a text box....on the same page, then to pick another option from the drop down menu and this then would be placed into another text box....say just underneath the first text box.....the code that i have at the moment is this:
<html>
<head>
<title>chose a team</title>
<script type='text/javascript'>
function doIt(selNum)
{
var selObj = document.theForm['rank'+selNum];
var prevNum = selNum-1;
var prevSel = document.theForm['rank'+prevNum]
selObj.options.length = 0;
for (var i = 0; i < prevSel.length; i++)
{
if (! prevSel.options[i].selected)
{
newItem = selObj.options.length;
selObj.options[newItem] = new Option(prevSel.options[i].text,
prevSel.options[i].value);
}
else {
document.theForm['text'+(selNum-1)].value = prevSel.options[i].text;
}
}
}
</script>
</head>
<body>
<h1><center>Chose a Team</center></h1>
<p>The teams</p>
<form name='theForm'><br>
<center><select name='rank1'onchange="doIt(2)">
<option value='Arsenal'>Arsenal</option>
<option value="Aston Villa">Aston Villa</option>
<option value="Birmingham">Birmingham</option>
<option value="Bolton">Bolton</option>
<option value="Chelsea">Chelsea</option>
<option value="Derby">Derby</option>
<option value="Everton">Everton</option>
<option value="Fulham">Fulham</option>
<option value="Liverpool">Liverpool</option>
<option value="Manchester City">Manchester City</option>
<option value="Manchester Utd">Manchester Utd</option>
<option value="Middlesboro">Middlesboro</option>
<option value="end of selection">end of selection</option>
</select></center><br>
<input type="text" name="text1"/>
<center><select name='rank2' onchange="doIt(3)">
</select></center>
<input type="text" name="text2"/>
<center><select name='rank3' onchange="doIt(4)">
</select></center>
<input type="text" name="text3"/>
<center><select name='rank4'>
</select></center>
</form>
</body>
</html>
as you can see this code gives me other drop down menus.....which i want to get rid of......but i can't work out how to do this.
any help would be very welcome
thanks
dav