# An issue with jQuery, simple button and hidden fields.

**URL:** https://community.ofelia.com/t/an-issue-with-jquery-simple-button-and-hidden-fields/4333
**Category:** Q&A
**Created:** [6 April 2014 09:42 UTC](https://community.ofelia.com/t/an-issue-with-jquery-simple-button-and-hidden-fields/4333 "2014-04-06T09:42:56Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![system](https://europe1.discourse-cdn.com/flex013/uploads/community_bonitasoft/original/2X/6/6b7b18c0478f2645369e82e009b65e3b97f2cc12.svg) [@system](https://community.ofelia.com/u/system)
#### Post date: [6 April 2014 09:42 UTC](https://community.ofelia.com/t/an-issue-with-jquery-simple-button-and-hidden-fields/4333/1 "2014-04-06T09:42:56Z")

</div>

Hello commrades! I have an issue with binding action on a simple button in Bonita BPM Studio (also there is another issue with hidden fields).

All actions are performed with BonitaForm.html file in C:%path\_to\_Bonita%\workspace\tomcat\bonita\client\platform\tenant-template\work\theme\portal and of course in the program.

In Studio I have added _Html widget_, _Hidden Field_, _Simple Button_ to the form with _submit button_. I’m trying to access the process variables through the JavaScript. But unfortunately, even a simple bind action on button does not work. I added a new class name to Simple Button _“createSpec”_ at \*Form Builder → Appearance → Field \*for easy accessing to element. Since jQuery is already connected in the file BonitaForm.html, I put the jQuery code into the Html Widget (_for some reason code refused to work when it is in file and connected in of BonitaForm.html_). So here are the code:

$(document).ready(function () { $('.createSpec').find(':last').click(function () { alert("RUNNING"); }); })

The following jQuery code [[http://jsfiddle.net/27Rf5/](http://jsfiddle.net/27Rf5/) ] is not working in Bonita when I running the process, but it works in simple .html file that I created and, as you see, in jsfiddle site.

What I’ve tried to:

- Put the jquery code into simple Button options, but it’s not working

- Change jQuery code to

$(document).ready(function () { $('#SimpleButton1').click(function () { alert("RUNNING"); }); })

And this works, but it binds the area line in browser instead of button.

**What should I change?**

**And another question** : To access the process variables through javaScript I should use Hidden field with binded String process variable to it. In javascript code I should access the Hidden field value by ID and then send to it value fro JS variable. But what should I do if I have a list of values that can dynamically change? In this case I can’t add Hidden Fileds, because I simply don’t know how much I will require them.

* * *

I am using Bonita BPM Studio Community 6.2.5, Java 7u51, Windows 7 x64

Regards,  
Igor

---

<div class="post-metadata">

### Author: ![system](https://europe1.discourse-cdn.com/flex013/uploads/community_bonitasoft/original/2X/6/6b7b18c0478f2645369e82e009b65e3b97f2cc12.svg) [@system](https://community.ofelia.com/u/system)
#### Post date: [4 June 2014 16:55 UTC](https://community.ofelia.com/t/an-issue-with-jquery-simple-button-and-hidden-fields/4333/2 "2014-06-04T16:55:40Z")

</div>

Hello Ozzoid, I have faced the same problem recently.

My suspicion is : the “$(document).ready(function () {” is not working as you are expecting.

The Portal builds and loads the page by blogs and some of them are loaded with and AJAX call.

I still haven’t gone deeper to understand how it works buy I will try it in the next days.

In the mean while… could you please try and change  
  
$(document).ready(function () {

for this:  
  
$(‘#SimpleButton1’).ready(function () {

Let me know if this fixes your problem or helps somehow.

Cheers,  
Jordi

---

<div class="post-metadata">

### Author: ![sfreue](https://avatars.discourse-cdn.com/v4/letter/s/e95f7d/32.png) [@sfreue](https://community.ofelia.com/u/sfreue)
#### Post date: [29 June 2014 00:40 UTC](https://community.ofelia.com/t/an-issue-with-jquery-simple-button-and-hidden-fields/4333/3 "2014-06-29T00:40:32Z")

</div>

I’ve had a similar problem, and after scratching my head for a while I moved the HTML Widget with the .change(… to the bottom of the form and it started working.

Hope it helps,

Sergio
