If you are unable to create a new account, please email support@bspsoftware.com

 

News:

MetaManager - Administrative Tools for IBM Cognos
Pricing starting at $2,100
Download Now    Learn More

Main Menu

JavaScript to Call Function Passing Parameters OnBlur

Started by Dhugu, 18 Nov 2016 08:56:38 AM

Previous topic - Next topic

Dhugu

I am trying to write javascript to validate multiple sets of TextBoxPrompts.   I want to use 1 function for all of the validation.  The HTML item with the function has been place at the top left corner of the prompt page.  Each TextBoxPrompt will have an HTML item to the right of it to call the function onblur passing it 1 parameter which is the name of the TextBoxPrompt.  The onblur works when no parameters are passed but not when the parameter is included.  When the parameter is included, the function is being fired on form load not with the onblur event.

At the top of the prompt page I have the function's code in an HTML item:

<script>
function validatePrompt( pFrom )
{
   alert("Got to the Function");
   return;
}
</script>


Code of HTML item after a TextBoxPrompt:

<script type= text/javascript>

var fW = (typeof getFormWarpRequest == "function" ? getFormWarpRequest() : document.forms["formWarpRequest"]);
if ( !fW || fW == undefined) { fW = ( formWarpRequest_THIS_ ? formWarpRequest_THIS_ : formWarpRequest_NS_ ); }

fW._textEditBoxRange_C_From.onblur = validatePrompt("Range_C_From");   //this does not work.  The function is being fired on form load not with the onblur event

// fW._textEditBoxRange_C_From.onblur = validatePrompt;   //this does work but would require a function per TextBoxPrompt which is what I am trying to avoid

</script>

Dhugu

Finally, I got it to work!  I created an inline function to all the validatePrompt function.

fW._textEditBoxRange_C_From.onblur = function callValidatePrompt()
         {
           validatePrompt("Range_C_From");
         }

Thanks for all the reads.  I hope this helps someone else.