Hi,
I'm looking to have a number of fields auto completed depending on which drop-down option id selected from a menu.
I've create a small funtion to do this for me, but the 'if' statement throughs up an error on submit.
Can anyone help?
getElementById('l') is the drop-down field
<script type="text/javascript">
<!--
function getValue(l) {
var ulocation = document.getElementById('l').options[l.selectedIndex].value;
If(ulocation == "Aberdeen");{
document.forms['newstarter'].elements['company'].value = "AddressLine1";
document.forms['newstarter'].elements['street'].value = 'AddressLine2';
document.forms['newstarter'].elements['city'].value = 'AddressLine3';
document.forms['newstarter'].elements['postcode'].value = 'AddressLine4';
}else if(ulocation == "London");{
document.forms['newstarter'].elements['company'].value = 'AddressLine1';
document.forms['newstarter'].elements['street'].value = 'AddressLine2';
document.forms['newstarter'].elements['city'].value = 'AddressLine3';
document.forms['newstarter'].elements['postcode'].value = 'AddressLine4';
}else if(ulocation == "Perth");{
document.forms['newstarter'].elements['company'].value = 'AddressLine1';
document.forms['newstarter'].elements['street'].value = 'AddressLine2';
document.forms['newstarter'].elements['city'].value = 'AddressLine3';
document.forms['newstarter'].elements['postcode'].value = 'AddressLine4';
}else{
return false;
}
}
// -->
</script>
Many thanks,
skothk
I'm looking to have a number of fields auto completed depending on which drop-down option id selected from a menu.
I've create a small funtion to do this for me, but the 'if' statement throughs up an error on submit.
Can anyone help?
getElementById('l') is the drop-down field
<script type="text/javascript">
<!--
function getValue(l) {
var ulocation = document.getElementById('l').options[l.selectedIndex].value;
If(ulocation == "Aberdeen");{
document.forms['newstarter'].elements['company'].value = "AddressLine1";
document.forms['newstarter'].elements['street'].value = 'AddressLine2';
document.forms['newstarter'].elements['city'].value = 'AddressLine3';
document.forms['newstarter'].elements['postcode'].value = 'AddressLine4';
}else if(ulocation == "London");{
document.forms['newstarter'].elements['company'].value = 'AddressLine1';
document.forms['newstarter'].elements['street'].value = 'AddressLine2';
document.forms['newstarter'].elements['city'].value = 'AddressLine3';
document.forms['newstarter'].elements['postcode'].value = 'AddressLine4';
}else if(ulocation == "Perth");{
document.forms['newstarter'].elements['company'].value = 'AddressLine1';
document.forms['newstarter'].elements['street'].value = 'AddressLine2';
document.forms['newstarter'].elements['city'].value = 'AddressLine3';
document.forms['newstarter'].elements['postcode'].value = 'AddressLine4';
}else{
return false;
}
}
// -->
</script>
Many thanks,
skothk