Multiple arguments in the onload function of a Page

Posted by IramK on 21-Nov-2014 10:01

Hello,

Is it not possible to have multiple arguments in the "onload" event of a New/Edit page? It doesn't work with multiple arguments but it does work with just one argument i.e. document.theForm.

Eg: if(typeof clearlistAndUpdateField == 'function')

      clearlistAndUpdateField(arg1, arg2, arg3);

Kindly let me know. 

Posted by Santosh Patel on 24-Nov-2014 04:17

With the following in onLoad for the page:

if(typeof clearlistAndUpdateField == 'function')

{

    clearlistAndUpdateField(document.theForm, 'a value', 'another value');

}

and following script component in the page:

<script>

 function clearlistAndUpdateField(form, arg2, arg3) {

 console.log(form);

 console.log(arg2);

 console.log(arg3);

}

</script>

I get the following result:

<form action=​"../​servlet/​Object" method=​"post" name=​"theForm" enctype=​"multipart/​form-data" onsubmit=​"rbf_disableAllButtons()​">​…​</form>​

a value

another value

The onLoad text (object definition > page definition > properties) area shown can contain arbitrary javascript content. There is really no restriction on the arguments for an onLoad function.  Where do you get values for your arg2 and arg3?

All Replies

Posted by Orchid Corpin on 21-Nov-2014 12:03

Hi,

Have you tried having curly braces "{}" in your if statement and inside it is your multiple arguments?

Regards,

Orchid

Posted by Santosh Patel on 24-Nov-2014 02:58

Hi IramK,

Please share the complete JS code that you are using. Will help us understand the problem better.

Posted by IramK on 24-Nov-2014 03:30

Yes I have tried using curly braces in my if statement but my function still doesn't work.

[mention:7e24e60fbecc4ff8baf4669a65bae0a0:e9ed411860ed4f2ba0265705b8793d05] : The onload function is similar to the function given above and the function declaration is as given below:

Onload:

if(typeof clearlistAndUpdateField == 'function')

{

     clearlistAndUpdateField(document.theForm, arg2, arg3);

}

JS Code:
<script> function clearlistAndUpdateField(form, arg2, arg3) { form.arg1 = arg2 + arg3; } </script>


Posted by Santosh Patel on 24-Nov-2014 04:17

With the following in onLoad for the page:

if(typeof clearlistAndUpdateField == 'function')

{

    clearlistAndUpdateField(document.theForm, 'a value', 'another value');

}

and following script component in the page:

<script>

 function clearlistAndUpdateField(form, arg2, arg3) {

 console.log(form);

 console.log(arg2);

 console.log(arg3);

}

</script>

I get the following result:

<form action=​"../​servlet/​Object" method=​"post" name=​"theForm" enctype=​"multipart/​form-data" onsubmit=​"rbf_disableAllButtons()​">​…​</form>​

a value

another value

The onLoad text (object definition > page definition > properties) area shown can contain arbitrary javascript content. There is really no restriction on the arguments for an onLoad function.  Where do you get values for your arg2 and arg3?

Posted by IramK on 24-Nov-2014 04:40

Yes that works. Not sure why it didn't work in the first place. Thanks for clearing it out.

This thread is closed