I was told to add the following code in a previously posted question to the form onload but when I add it to the bottom of the already existing code I get a weird error that pops up when trying to resolve the case. The code is listed below I'll remark where the new code is that causes the error:
crmForm.all.tab1Tab.style.
display = "none"; //hide
var CRM_FORM_TYPE_CREATE = 1;
var CRM_FORM_TYPE_UPDATE = 2;
// Only enable the dynamic picklist on a Create or Update form. Disabled and
// read-only forms are not editable and so do not require dynamic picklists.
switch (crmForm.FormType)
{
case CRM_FORM_TYPE_CREATE:
case CRM_FORM_TYPE_UPDATE:
// Get a reference to the Sub-Industry picklist element for later use
var ocategoryofservice = crmForm.all.new_categoryof
service;
// Cache the original picklist "Options" array in an "expando" on the
// element. We will use this original list to dynamicly re-build the picklist
// based on the Industry the user selects.
ocategoryofservice.origina
lPicklistO
ptions = ocategoryofservice.Options
;
// If there is not an Industry selected, we just need to disable the
// Sub-Industry. As soon as the user selects an Industry, we will
// re-enable the Sub-Industry picklist.
if (crmForm.all.casetypecode.
DataValue == null)
{
ocategoryofservice.Disable
d = true;
}
else
{
if(ocategoryofservice.Data
Value == null)
{
// There is an industry value already selected, but not a subindustry.
// Limit the available options to what is valid for the currently
// selected Industry value. The code to do this already exists in the
// Industry Picklist's onchange event. Re-use that code by manually
// firing the event.
casetypecode_onchange0();
}
}
break;
}
// Insert this function into your form
// OnLoad event.
//CalcHours = function() {
// MinsWorked = crmForm.all.crihb_timespen
tmin.Selec
tedText;
// if (MinsWorked == null)
// MinsWorked = ".00";
// TotalWorked = crmForm.all.crihb_timespen
thrs.DataV
alue + MinsWorked;
// crmForm.all.crihb_totalhou
rs.DataVal
ue = parseFloat(TotalWorked);
//} // CalcHours function
CalcHours = function() {
MinsWorked = crmForm.all.crihb_timespen
tmin.Selec
tedText;
if ((MinsWorked == null) || (MinsWorked == "")) {
MinsWorked = "0"; }
MinsFractWorked = parseFloat(MinsWorked)/60;
TotalWorked = crmForm.all.crihb_timespen
thrs.DataV
alue + MinsFractWorked;
crmForm.all.crihb_totalhou
rs.DataVal
ue= parseFloat(TotalWorked);
} // CalcHours function
var currentDate = new Date();
if(crmForm.FormType == 1)
{
crmForm.all.new_startdate.
DataValue = currentDate;
}
if(crmForm.FormType == 2 && crmForm.all. new_startdate.DataValue == null)
{
crmForm.all. new_startdate.DataValue = currentDate;
}
THE CODE BELOW CAUSES PROBLEMS
// Get the Industry Element, since this code is re-used by the form's onload event
// we can not rely on the event.srcElement to have the approriate element.
var ocasetypecode = crmForm.all.casetypecode ;
// Initialize the Sub-Industry indexes
var iStartIndex = -1;
var iEndIndex = -1;
// Depending on what the user selects in the Industry picklist, we will select
// a range of options in the Sub-Industry picklist to display.
//
// For the purposes of this sample, it is assumed that the display text of each
// Industry will be known and will not be localized. We have also ordered the
// options in the Sub-Industry picklist so that they are group sequentially per
// Industry. This allows the code to simply define start and stop Sub-Industry
// indexes for each Industry.
switch (ocasetypecode .SelectedText)
{
case "Training":
iStartIndex = 1;
iEndIndex = 12;
break;
case "Technical Assistance":
iStartIndex = 13;
iEndIndex = 26;
break;
case "Resource Development":
iStartIndex = 27;
iEndIndex = 29;
break;
case "Advocacy":
iStartIndex = 30;
iEndIndex = 31;
break;
}
// Get a reference to the Sub-Industry picklist element for later use
var ocategoryofservice= crmForm.all.new_categoryof
service;
// If the indexes where set, update the Sub-Industry picklist
if (iStartIndex > -1 && iEndIndex > -1)
{
// Create a new array, which will hold the new picklist options
var oTempArray = new Array();
// Initialize the index for the temp array
var iIndex = 0;
// Now loop through the original Sub-Industry options, pull out the
// requested options a copy them into the temporary array.
for (var i = iStartIndex; i <= iEndIndex; i++)
{
oTempArray[iIndex] = ocategoryofservice.origina
lPicklistO
ptions[i];
iIndex++;
}
// Reset the Sub-Industry picklist with the new options
ocategoryofservice.Options
= oTempArray;
// Enable the Sub-Industry picklist for the user
ocategoryofservice.Disable
d = false;
}
else
{
// The user has selected an unsupported Industry or no Industry
ocategoryofservice.DataVal
ue = null;
ocategoryofservice.Disable
d = true;
}