The CreatorCon Call for Content is officially open! Get started here.

how get the values of hidden fields in client script?

revathy
Kilo Expert

Hi all,

I have a client script where i need to get the value of a hidden field in a form is it possible?

script:

-------

var a = g_form.getValue('task_number');

alert(a);

I am not getting any value when i give alert.

Thanks.

1 ACCEPTED SOLUTION

Anurag Tripathi
Mega Patron
Mega Patron

Bring the field on the form display and hide it using g_form.setDisplay


Then you will be able to read it as its present on the form. if its not in the layout itself then you will have to read it from server side and will have to make an ajax call for it, long way.


-Anurag

View solution in original post

6 REPLIES 6

Anurag Tripathi
Mega Patron
Mega Patron

Bring the field on the form display and hide it using g_form.setDisplay


Then you will be able to read it as its present on the form. if its not in the layout itself then you will have to read it from server side and will have to make an ajax call for it, long way.


-Anurag

Harsh Vardhan
Giga Patron

you need to use display business rule and and get the field value thrugh g_scratchpad and call it in client script.


check the script below i have tested it and it's working.



Display BR:



(function executeRule(current, previous /*null when async*/) {




// Add your code here


g_scratchpad.categoryfield = current.category.getDisplayValue();





})(current, previous);



Client script:


function onLoad() {


    //Type appropriate comment here, and begin script below


    alert('testing ' + g_scratchpad.categoryfield);


}




Thanks,


Harshvardhan