Changes

JavaScript - Outcome functionality extension

1,679 bytes added, 01:30, 31 July 2014
Created page with "In BeX, there is no direct way to add onchange functionality to an outcome drop down list. It is however possible to extend the functionality of any drop down element with cu..."
In bxp, there is no direct way to add onchange functionality to an outcome drop down list. It is however possible to extend the functionality of any drop down element with custom JavaScript.

The following can be added to your onLoad of the form.


<syntaxhighlight lang="javascript">

// Based on http://stackoverflow.com/questions/6831528/add-a-second-onchange-event
//===================================================================
function fn_General_onChange_AppendFunction ( strObjectName ) {

//If that select exists
if (document.getElementById(strObjectName)) {

//Get the object
var objObject = document.getElementById(strObjectName);

//Modern browsers
if (objObject.addEventListener) {
objObject.addEventListener("change", function(e){
e = e || event;
//Calls your custom function
fn_MyCustomFunction();
}, false);
}
// Older browsers (IE 5 - 8)
else if (objObject.attachevent) {
objObject.attachEvent("onchange", function(e){
e = e || event;
//Calls your custom function
fn_MyCustomFunction();
});
}
}
}
//===================================================================
function fn_MyCustomFunction() {

//Gets the current outcome chosen
var strContact_Outcome == document.getElementById ('strContact_Outcome').value;

//if this is the outcome you want to do something with.
if ( strContact_Outcome == 'Your Outcome' ) {
//Perform some action
}

}
//===================================================================
//Now kick it off
fn_General_onChange_AppendFunction ( 'strContact_Outcome' );
//===================================================================


</syntaxhighlight>
7,528
edits