civicstiil
New Coder
Would someone kindly help me with the below? Built this simple javacsript form a few years ago and recently stopped working once my firm updated browsers. Can't figure this one out! When selecting the "team" - it's supposed to populate the mascot and the color. The mascot populates but color says "undefined". Hopefully an easy fix!
HTML:
<HTML>
<HEAD>
<script>
<!--
function populate(item){
for(var i=0;i<item.form.elements.length;i++){
if(item==item.form.elements[i]){
item.form.elements[i+1].value=
item.options[item.selectedIndex].value;
}
}
for(var i=0;i<item.form.elements.length;i++){
if(item==item.form.elements[i]){
item.form.elements[i+2].value=
item.options[item.selectedIndex].value2;
}
}
}
// -->
</script>
</HEAD>
<BODY>
<form>
Team: <select onchange="populate(this)"><option value="" value2="">--- Select Account ---</option>
<option value="Billy" value2="Blue">Bluebirds</option>
<option value="Hal" value2="Brown">Owls</option>
<option value="Tony" value2="Red">Hawks</option>
</Select>
<BR>
Mascot: <input type="text" /readonly>
<BR>
Color: <input type="text" /readonly>
</form>
</BODY>
</HTML>
Last edited by a moderator: