Hello everyone. I inherited some code from a previous employee. In short this code allows a member of the sales team to search records of companies from the website.
It functions fine in Internet explorer. But will fail at the same spot on any other browser upon form submit.
Error on submit:
[CODE]Element param0Criteria is undefined in a Java object of type class coldfusion.filter.FormScope
In addition to that error, when another search criteria is is pressed (function addNewParam()) to be added, I get this error from the Java console.
[CODE]Uncaught TypeError: Cannot read property ‘value’ of undefined
[B]In short: Firefox and the like, can’t see the form element param#Criteria. function paramCode writes the option.
[B]This thing is massive, so I cut it down and put it into sections as best as I could.
[U]Thank you for any help you can give. I am very appreciative.
MAIN CODE BELOW:
[CODE]<script language=”JavaScript”>
…..
function addNewParam()
{
var oNewParam;
recacheParams();
oNewParam = new Object();
oNewParam.criteria = ‘company_name’;
oNewParam.type = ‘starts_with’;
oNewParam.string = ”;
oParam[iParamCount] = oNewParam;
iParamCount++;
refreshParams();
}
function refreshParams()
{
var iCounter;
var sOutput = ”;
sOutput += ‘<table cellspacing=”0″ cellpadding=”0″ border=”0″ width=”100%”>’;
//document.form1.paramCount.value = iParamCount;
document.forms[‘form1’][‘paramCount’].value = iParamCount;
for(iCounter = 0; iCounter < iParamCount; iCounter++)
sOutput += rowCode(iCounter, oParam[iCounter]);
sOutput += ‘</table>’;
obj(‘searchTable’).innerHTML = sOutput;
}
function recacheParams()
{
var iCounter;
//iParamCount = document.form1.paramCount.value;
iParamCount = document.forms[‘form1’][‘paramCount’].value;
for(iCounter = 0; iCounter < iParamCount; iCounter++)
oParam[iCounter] = getParam(iCounter);
}
function getParam(iIndex)
{
var oParam = new Object();
//oParam.criteria = document.form1[‘param’ + iIndex + ‘Criteria’].value;
oParam.criteria = document.forms[‘form1’][‘param’ + iIndex + ‘Criteria’].value;
alert(document.forms[‘form1’][‘logic’].value);
switch(oParam.criteria)
{
case ‘company_name’:
case ‘street’:
case ‘city’:
case ‘zip’:
case ’email’:
case ‘phone_number’:
oParam.type = document.form1[‘param’ + iIndex + ‘Type’].value;
if(oParam.type == ‘contains’ || oParam.type == ‘starts_with’)
oParam.string = document.form1[‘param’ + iIndex + ‘String’].value;
else if(oParam.type == ‘is_duplicated’)
oParam.characters = document.form1[‘param’ + iIndex + ‘Characters’].value;
break;
case ‘location’:
oParam.type = document.form1[‘param’ + iIndex + ‘Type’].value;
oParam.string = document.form1[‘param’ + iIndex + ‘String’].value;
oParam.blanks = document.form1[‘param’ + iIndex + ‘Blanks’].value;
break;
case ‘dealer_status’:
case ‘distributor_status’:
case ‘manufacturer_status’:
case ‘rep_status’:
case ‘vendor_status’:
case ‘user_count’:
oParam.status = document.form1[‘param’ + iIndex + ‘Status’].options[document.form1[‘param’ + iIndex + ‘Status’].selectedIndex].value;
break;
case ‘company_type’:
oParam.metric = document.form1[‘param’ + iIndex + ‘Metric’].options[document.form1[‘param’ + iIndex + ‘Metric’].selectedIndex].value;
oParam.type = document.form1[‘param’ + iIndex + ‘Type’].options[document.form1[‘param’ + iIndex + ‘Type’].selectedIndex].value;
break;
case ‘rep_territory’:
oParam.repFirmID = document.form1[‘param’ + iIndex + ‘RepFirmID’].options[document.form1[‘param’ + iIndex + ‘RepFirmID’].selectedIndex].value;
break;
case ‘salesperson’:
oParam.metric = document.form1[‘param’ + iIndex + ‘Metric’].options[document.form1[‘param’ + iIndex + ‘Metric’].selectedIndex].value;
oParam.salespersonID = document.form1[‘param’ + iIndex + ‘SalespersonID’].options[document.form1[‘param’ + iIndex + ‘SalespersonID’].selectedIndex].value;
break;
case ‘marketingcampaign’:
oParam.campaignID = document.form1[‘param’ + iIndex + ‘campaignID’].options[document.form1[‘param’ + iIndex + ‘campaignID’].selectedIndex].value;
break;
case ‘isnewcontact’:
oParam.newContact = document.form1[‘param’ + iIndex + ‘newContact’].options[document.form1[‘param’ + iIndex + ‘newContact’].selectedIndex].value;
break;
case ‘totalbusiness’:
oParam.metric = document.form1[‘param’ + iIndex + ‘Metric’].options[document.form1[‘param’ + iIndex + ‘Metric’].selectedIndex].value;
oParam.totalB = document.form1[‘param’ + iIndex + ‘Total’].value;
break;
case ‘latestnote’:
oParam.metric = document.form1[‘param’ + iIndex + ‘Metric’].options[document.form1[‘param’ + iIndex + ‘Metric’].selectedIndex].value;
oParam.latestID = document.form1[‘param’ + iIndex + ‘LatestID’].options[document.form1[‘param’ + iIndex + ‘LatestID’].selectedIndex].value;
break;
}
return oParam;
}
function optionCode(sValue, sText, sVariable)
{
return ‘<option value=”‘ + sValue + ‘”‘ + (sVariable == sValue ? ‘ selected’ : ”) + ‘>’ + sText + ‘</option>’;
}
….