I am trying to create a filter for users selecting a subscription. The selector is populated on blur of zip text box and choice of paper by radio button. I had it working for three papers but when I added a fourth I got lost. I can’t get the selector to popluate with the correct corresponding population.
Any zipcode that does not start with 119 qualifies as Out of County. Or STOut, SIOut, NSOut, NROut
The radio buttons appear in this order
ST
NR
NS
SI
Can anyone help?
<code>// This function called from PopulateType and is used to set the values & names for the
// rate fields, based on zip & editiontype.
function populate(o){
//d=document.getElementById(‘sp_rate_type’);
d=document.nsForm.sp_rate_type
if(!d){return;}
var mitems=new Array();
var mvalues=new Array();
// VALUES & CODES ————————————————–
// STIn
// 0 1 Year $35.00 120
// 1 9 Month Student $35.00 94
// 2 Online Edition $26.00 123
mitems[‘STIn’]=new Array();
mvalues[‘STIn’]=[‘120′,’94’,’123′];
mitems[‘STIn’][0]=[‘One year mailed to your home. – $35.00’];
mitems[‘STIn’][1]=[‘Student subscription: Sept-May. – $35.00’];
mitems[‘STIn’][2]=[‘Online Edition – $26.00’];
// STOut
// 0 1 Year $44.00 121
// 1 9 Mo. student $35.00 94
// 2 Online Edition $26.00 123
mitems[‘STOut’]=new Array();
mvalues[‘STOut’]=[‘121′,’94’,’123′];
mitems[‘STOut’][0]=[‘One year mailed to your home. – $44.00’];
mitems[‘STOut’][1]=[‘Student subscription: Sept-May – $35.00’];
mitems[‘STOut’][2]=[‘Online Edition – $26.00’];
// NRIn
// 0 1 Year $35.00 98
// 1 9 Month Student $35.00 101
// 2 Online Edition $26.00 123
mitems[‘NRIn’]=new Array();
mvalues[‘NRIn’]=[’98’,’101′,’123′];
mitems[‘NRIn’][0]=[‘One year mailed to your home. – $35.00’];
mitems[‘NRIn’][1]=[‘Student subscription: Sept-May. – $35.00’];
mitems[‘NRIn’][2]=[‘Online Edition – $26.00’];
// NROut
// 0 1 Year $44.00 99
// 1 9 Mo. student $35.00 101
// 2 Online Edition $26.00 123
mitems[‘NROut’]=new Array();
mvalues[‘NROut’]=[’99’,’101′,’123′];
mitems[‘NROut’][0]=[‘One year mailed to your home. – $44.00’];
mitems[‘NROut’][1]=[‘Student subscription: Sept-May – $35.00’];
mitems[‘NROut’][2]=[‘Online Edition – $26.00’];
// NSIn
// 0 1 Year $25.00 112
// 1 9 mo. student $25.00 115
// 2 Online Edition $26.00 126
mitems[‘NSIn’]=new Array();
mvalues[‘NSIn’]=[‘112′,’115′,’126’];
mitems[‘NSIn’][0]=[‘One year mailed to your home. – $25.00’];
mitems[‘NSIn’][1]=[‘Student subscription: Sept-May. – $25.00’];
mitems[‘NSIn’][2]=[‘Online Edition – $26.00’];
// NSOut
// 0 1 Year $35.00 113
// 1 9 mo. student $25.00 115
// 2 Online Edition $26.00 126
mitems[‘NSOut’]=new Array();
mvalues[‘NSOut’]=[‘113′,’115′,’126’];
mitems[‘NSOut’][0]=[‘One year mailed to your home. – $35.00’];
mitems[‘NSOut’][1]=[‘Student subscription: Sept-May. – $25.00’];
mitems[‘NSOut’][2]=[‘Online Edition – $26.00’];
// SIIn
// 0 1 Year $30.00 11
// 1 9 mo. student $30.00 108
// 2 Online Edition $26.00 125
mitems[‘SIIn’]=new Array();
mvalues[‘SIIn’]=[‘106′,’108′,’125’];
mitems[‘SIIn’][0]=[‘One year mailed to your home. – $30.00’];
mitems[‘SIIn’][1]=[‘Student subscription: Sept-May. – $30.00’];
mitems[‘SIIn’][2]=[‘Online Edition – $26.00’];
// SIOut
// 0 1 Year $38.00 106
// 1 9 mo. student $30.00 108
// 2 Online Edition $26.00 125
mitems[‘SIOut’]=new Array()
mvalues[‘SIOut’]=[‘106′,’108′,’125’];
mitems[‘SIOut’][0]=[‘One year mailed to your home. – $38.00’];
mitems[‘SIOut’][1]=[‘Student subscription: Sept-May. – $30.00’];
mitems[‘SIOut’][2]=[‘Online Edition – $26.00’];
d.options.length=0;
cur=mitems[o];
curval=mvalues[o];
if(!cur){return;}
d.options.length=cur.length;
for(var i=0;i<cur.length;i++)
{
d.options[i].text=cur[i];
d.options[i].value=curval[i];
}
}
// This function called when the zip field blurs, or when the edition type is changed.
// Also, called onLoad to repopulate (after zip & editiontype have been repopulated)
function populateType(myitem) {
var i=0;
var curid=-1;
for (i=0;i<document.nsForm.editiontype.length;i++){
if (document.nsForm.editiontype[i].checked==true){
curid=i;
}
}
if (curid==-1){
return false;
}
document.nsForm.del_zip_readonly.value=document.nsForm.del_zip.value;
var pZipIn = /^119dd$/;
if (!(pZipIn.test(document.nsForm.del_zip.value))==0){
if (curid==2){
populate(“STIn”);
} else if (curid==1) {
populate(“NRIn”);
} else if (curid==1) {
populate(“NSIn”);
} else {
populate(“SIIn”);
}
} else {
if (curid==2){
populate(“STOut”);
} else if (curid==1) {
populate(“NROut”);
} else if (curid==1) {
populate(“NSOut”);
} else {
populate(“SIOut”);
}
}
}
<code>