Where to use javascript in HTML widget

1
0
-1

i use following code , all done well but javascirpt not working

<head>
<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

Comments

Submitted by domenico.giordano on Mon, 04/07/2014 - 15:52

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:

<script type="text/javascript">
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

Submitted by domenico.giordano on Mon, 04/07/2014 - 15:54

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:

<script type="text/javascript">
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

Submitted by kppatel on Mon, 04/07/2014 - 16:00

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

1 answer

1
0
-1

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:

StringBuilder sb=new StringBuilder("<script>");
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:

onclick="setData();"

Hope that I am clear and it solve your problem Ciao.

Comments

Submitted by kppatel on Thu, 04/10/2014 - 13:39

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

Submitted by domenico.giordano on Fri, 04/18/2014 - 11:29

Hi, sorry for the delay. You have to add a HTML Widget. Click on "data" under "General" tab. click on the little pencil aside the "Initial value". Then select "script" and past the code above. Let me know if now it is more clear. Ciao.

Submitted by kppatel on Mon, 04/21/2014 - 06:35

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"

Submitted by Sean McP on Tue, 04/07/2015 - 07:37

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

Submitted by gdkannanit94 on Mon, 07/06/2015 - 09:51

please tell me again briefly how to do this

Submitted by Sean McP on Mon, 07/06/2015 - 14:23

Everything you need is above, there is nothing more to say...

regards

Notifications