Question

Virtusa
AU
Last activity: 18 Aug 2020 7:42 EDT
Passing values from javascript to jsp is not working
I am trying to pass values from js to jsp not able to get the values. Can any one know how to pass values or can anyone help me with how to get the value from DOM using jsp.
My javascript code:
<% String uuid = java.util.UUID.randomUUID().toString() ; %> <span id="sectionamepicker<%= uuid %>"> </span>
<pega:reference name ="Param.Inskey" /> <script>
function getIns() { var element = $('#sectionamepicker<%= uuid %>').parents('div[objclass="Rule-HTML-Section"]')[0]; var ClassName = element.getAttribute("pyclassname"); var Inskey = element.getAttribute("data-ui-meta"); var Inskey_split = Inskey.split(","); var key_value = Inskey_split[2].split(":"); var Ins= key_value[1]; console.log(Ins); return Ins; } var Insval = getIns(); function getpath() { var element = $('#sectionamepicker<%= uuid %>').parents('div[class $="custom-control"]')[0]; console.log(element); var Path = element.getAttribute("data-ui-meta"); var Path_split = Path.split(","); var Path_value = Path_split[4].split(":"); var value =Path_value[1].substring(0, Path_value[1].length - 1); console.log(value); return value;
} var pathval = getpath();
I am trying to pass values from js to jsp not able to get the values. Can any one know how to pass values or can anyone help me with how to get the value from DOM using jsp.
My javascript code:
<% String uuid = java.util.UUID.randomUUID().toString() ; %> <span id="sectionamepicker<%= uuid %>"> </span>
<pega:reference name ="Param.Inskey" /> <script>
function getIns() { var element = $('#sectionamepicker<%= uuid %>').parents('div[objclass="Rule-HTML-Section"]')[0]; var ClassName = element.getAttribute("pyclassname"); var Inskey = element.getAttribute("data-ui-meta"); var Inskey_split = Inskey.split(","); var key_value = Inskey_split[2].split(":"); var Ins= key_value[1]; console.log(Ins); return Ins; } var Insval = getIns(); function getpath() { var element = $('#sectionamepicker<%= uuid %>').parents('div[class $="custom-control"]')[0]; console.log(element); var Path = element.getAttribute("data-ui-meta"); var Path_split = Path.split(","); var Path_value = Path_split[4].split(":"); var value =Path_value[1].substring(0, Path_value[1].length - 1); console.log(value); return value;
} var pathval = getpath();
</script>
In this js code i am fetching values from DOM but my problem is not able to pass it to jsp because jsp run on server so it executes first and js is running. If anyone know how to write my js code in java ?