Where to use javascript in HTML widget
i use following code , all done well but javascirpt not working
<script type="text/javascript">
function ChooseContact(data) {
document.getElementById ("friendName").value = data.value;
}
</script>
</head>
<body>
<select onchange="ChooseContact(this)">
<option value='1'>1</option>
<option value='2'>2</option>
</select>
<input id="friendName">
</body>
thanks kadnarp
Hi. You can use a REST API call via jQuery.ajax() method. Let me simplify and give a simple code. Add a new HTML widget and in the date add this Java code:
sb.append("function setData() {");
sb.append("var newValue=\$('#friendName').val();");
sb.append("var parameters = {'id':'").append(processInstanceId).append("/testdata', name:'testdata',type:'java.lang.String',value:newValue};");
sb.append("\$.ajax({type: 'PUT',url: '/bonita/API/bpm/caseVariable/").append(processInstanceId).append("/testdata',");
sb.append("data: JSON.stringify(parameters),");
sb.append("contentType: 'application/json; charset=utf-8'");
sb.append("}).done(function (data, textStatus, jqXHR) {");
sb.append("\$('.submit').click();});}");
sb.append("</script>")
sb.toString();
In this way you can add enviroment data like processInstanceId that is mandatory if you would modify a process instance data. and add a SimpleButton and add this HTML option:
Hope that I am clear and it solve your problem Ciao.
Comments
Sir thank you for your reply , but i m totally new in this environment . i create one html widget now exactly where i should have to write the code which you provided and i want when click on button . data should be set as well as store on variable for further use
Thanks again for reply . but due to new in this environment , i need some more detail description if possible
thanks in advance
hello,
sir i take one html widget and paste code as data , and take one simple button and paste html option but when i run form it give error : " error while submitting form"
There is one important piece of information missing here, you must also (for this example) have a pool variable called "testdata" of type text.
Then it will work fine.
regards
please tell me again briefly how to do this
Everything you need is above, there is nothing more to say...
regards
Comments
Hi I am sure about your question. But let me say taht if you would like to add that code in a HTML widget that render a select box and a text and than manage contingency between this select box and the text, you can adda a HTML widget and add this code as widget data:
function ChooseContact(data) {
document.getElementById ("friendName").value = data.value;
}
</script>
<select onchange="ChooseContact(this)">
<option value='1'>1</option>
<option value='2'>2</option>
</select>
<input id="friendName">
Let me know if it can help you
Hi I am sure about your question. But let me say taht if you would like to add that code in a HTML widget that render a select box and a text and than manage contingency between this select box and the text, you can adda a HTML widget and add this code as widget data:
function ChooseContact(data) {
document.getElementById ("friendName").value = data.value;
}
</script>
<select onchange="ChooseContact(this)">
<option value='1'>1</option>
<option value='2'>2</option>
</select>
<input id="friendName">
Let me know if it can help you
Hello , Thank you so much for your reply :)
I do , Take one html widget field And on data tab of that field I put that code It working fine . But now I want to store data which in Return in text filed into variable of bonitasoft ? Now how can i achive that