- Feb 22, 2005
- 7,280
- 0
- 0
I'm trying to remove option values from a standard form, using some javascript. Basically I don't have access to the source of the form itself, and I'd like to show only the options I want. The first part, trimCountry, works fine. The second part, trimProvince, does not, and I suspect it's because of how I have it setup to look for multiple values. I don't see any errors on the page itself, it just doesn't work. Forgive my formatting 
<script language="JavaScript">
if(document.getElementById('frmPayment').ordCountry)
TrimCountry(document.getElementById('frmPayment').ordCountry);
if(document.getElementById('frmPayment').shipCountry)
TrimCountry(document.getElementById('frmPayment').shipCountry);
if(document.getElementById('frmPayment').ordProvince)
TrimProvince(document.getElementById('frmPayment').ordProvince);
if(document.getElementById('frmPayment').shipProvince)
TrimProvince(document.getElementById('frmPayment').shipProvince);
function TrimCountry(selObj){
for (i= selObj.options.length -1; i >= 0 ; i--) {
if(selObj.options.value != 'CA')
selObj.options = null;
}
}
function TrimProvince(selObj) {
for (i= selObj.options.length -1; i >= 0 ; i--) {
if(selObj.options.value != 'AB' || selObj.options.value != 'BC' || selObj.options.value != 'MB' || selObj.options.value != 'NB' || selObj.options.value != 'NL' || selObj.options.value != 'NT' || selObj.options.value != 'NU' || selObj.options.value != 'ON' || selObj.options.value != 'PE' || selObj.options.value != 'SK' || selObj.options.value != 'NS' || selObj.options.value != 'QC') selObj.options = null;
}
}
</script>
Any ideas?
<script language="JavaScript">
if(document.getElementById('frmPayment').ordCountry)
TrimCountry(document.getElementById('frmPayment').ordCountry);
if(document.getElementById('frmPayment').shipCountry)
TrimCountry(document.getElementById('frmPayment').shipCountry);
if(document.getElementById('frmPayment').ordProvince)
TrimProvince(document.getElementById('frmPayment').ordProvince);
if(document.getElementById('frmPayment').shipProvince)
TrimProvince(document.getElementById('frmPayment').shipProvince);
function TrimCountry(selObj){
for (i= selObj.options.length -1; i >= 0 ; i--) {
if(selObj.options.value != 'CA')
selObj.options = null;
}
}
function TrimProvince(selObj) {
for (i= selObj.options.length -1; i >= 0 ; i--) {
if(selObj.options.value != 'AB' || selObj.options.value != 'BC' || selObj.options.value != 'MB' || selObj.options.value != 'NB' || selObj.options.value != 'NL' || selObj.options.value != 'NT' || selObj.options.value != 'NU' || selObj.options.value != 'ON' || selObj.options.value != 'PE' || selObj.options.value != 'SK' || selObj.options.value != 'NS' || selObj.options.value != 'QC') selObj.options = null;
}
}
</script>
Any ideas?

