View Single Post
Old 08-28-2012, 04:48 PM   PM User | #1
tony0706
New to the CF scene

 
Join Date: Aug 2012
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
tony0706 is an unknown quantity at this point
Showing arrays based on conditions

Hi all,

I am relatively new to the forum, so I apologize if I am out of line asking generic questions on Javascripts.

The issue I am having is showing arrays or hiding arrays based on selections of a drop-down menu then again for a checkbox or toggle selection. I managed to accomplish only half of this, is javascript capable of doing so? pasted below is working code for showing and hiding arrays based on one condition ( the drop down selection)

Thanks for the help !

Code:
function togglespan(strState,strSpanList) {
// shows or hides an array of elements
	var arrSpanList=strSpanList.split(";");
	// parse the array
	for (strSpanID in arrSpanList) {
		if (!strState) {
			if (document.getElementById(arrSpanList[strSpanID]).style.display=='none') {
				document.getElementById(arrSpanList[strSpanID]).style.display='block';
			} else if (document.getElementById(arrSpanList[strSpanID]).style.display=='block') {
				document.getElementById(arrSpanList[strSpanID]).style.display='none';
			}
		} else if (strState!='null'){
			document.getElementById(arrSpanList[strSpanID]).style.display=strState;
		}
	}
}
function changeValue(strValue,strInput) {
// update form fields with the requested template
	document.getElementById(strInput).value = strValue;
	switch (strValue) {
	case 'Email - Standard':
		updateSignature();
		document.getElementById('alertspan').innerHTML="<b style='background-color:white;color:red;font-size:14px;font-family:segoe UI'>Please remember to <u>Always proof read emails</u> before sending them to your customer</b><br />";
		togglespan('block','customernamespan;servicerequestnumberspan;servicerequestnumberspan;standardspan;signaturespan');
		togglespan('none','casewellnessspan;rimcasenumberspan;onbehalfofspan;timezonespan;randomcodespan;SOAP;PSIDTemplate;closing;batchdatespan;businessjustifcation;emailaddressspan;phonenumberspan;tslconsultspan;optinspan;optspan;psidstandardspan');
		document.getElementById('ptochange').innerHTML = 'Email Message Body:';
		document.form1.standard.value = document.form1.assessment.value;
		break;
	case 'Email - Unsupported':
		updateSignature();
		document.getElementById('alertspan').innerHTML="<b style='background-color:white;color:red;font-size:14px;font-family:segoe UI'>Please remember to <u>Always proof read emails</u> before sending them to your customer</b><br />";
		togglespan('block','customernamespan;servicerequestnumberspan;standardspan;signaturespan');
		togglespan('none','casewellnessspan;rimcasenumberspan;onbehalfofspan;timezonespan;randomcodespan;SOAP;PSIDTemplate;closing;batchdatespan;businessjustifcation;emailaddressspan;phonenumberspan;tslconsultspan;optspan;optinspan;psidstandardspan');
		document.getElementById('ptochange').innerHTML = 'Unsupported issue:';														
		break;
	case 'Email - Closing':
		updateSignature();
		document.getElementById('alertspan').innerHTML="<b style='background-color:white;color:red;font-size:14px;font-family:segoe UI'>Please remember to <u>Always proof read emails</u> before sending them to your customer</b><br />";
		togglespan('none','casewellnessspan;rimcasenumberspan;onbehalfofspan;timezonespan;randomcodespan;SOAP;PSIDTemplate;batchdatespan;businessjustifcation;emailaddressspan;phonenumberspan;tslconsultspan;optspan;optinspan;psidstandardspan');
		togglespan('block','standardspan;customernamespan;servicerequestnumberspan;closing;signaturespan');
		document.getElementById('ptochange').innerHTML = 'Issue Description: ';
		document.form1.standard.value = document.getElementById('ProblemStatement').value;
		document.form1.input4.value = document.form1.assessment.value;
		break;
.....
PS

I added the ... on the end because it repeats basically.
tony0706 is offline   Reply With Quote