You are viewing limited content. For full access, please sign in.

Question

Question

Save value of readonly checkbox

asked on February 3, 2017

I have a form with a checkbox field with two options. The idea is that the user cannot modify this field because the value is sent as a parameter on the URL and the value is set through JavaScript. However, when the form is submitted, the form's checkbox doesn´t have any value set.

According to the suggestions, the field is being set read-only through JavaScript and not throught the editor.

Is there any way to solve this?

Form Preview

After form is submitted

We are using Forms 10.1.0.579

 

 

0 0

Replies

replied on February 6, 2017

Hello,

Can you upload the screenshot of CSS and Javascript page? Thank you

0 0
replied on February 7, 2017

Yes of course,

0 0
replied on February 7, 2017

Hello,

I don't think this will help but have you also tried to set read-only in field configuration and only set values with your custom javascript?? 

Please correct me if I misunderstand, your checkbox field configuration is in initial state, no modifications made (except number of options), and you are trying to set value and set it as read-only with your custom javascript. When opening a form, everything is fine, but once the form gets submitted, the value is lost and field is still in read-only mode. 

Thank you

0 0
replied on February 7, 2017

In general, according to the documentation, if a field that has been set read-only from the form editor is modified trhrough Javascript, the value won´t be kept after the form is submitted.

As an alternative, I set the readonly property from the CSS and Javascript section and then, if the field is modified somehow through Javascript, then the value is kept even after form submission. This has proven to work on text inputs, but with checkboxes is not working, which is why I would like to know why the value gets lost.

In the initial configuration the checkbox field is editable, and the only changes made are the options added from the editor page.

0 0
replied on February 15, 2017

Hello, sorry for the late reply.

Since you are getting the value from the url, let's first try and see if your value is kept in the url after the submission. Can you please try add a line 'console.log(datos.op)' at line 3 (at line between 'var datos = ...' and 'var op = ...').

After adding the line, and run process, press F12 key to open console and submit the form. After submission, you should see the correct value in console page. 

0 0
replied on February 17, 2017 Show version history

Hello,

After the submission of the form, the console log shows that datos.op is undefined.

As a workaround, I added a click event on the Submit button, so that the checkbox field's disabled property is removed. That way, the value is kept after form submission. This is the code I used:

$('.Submit').on('click', function(){
	$('#Field1-0').attr('disabled', false);
	$('#Field1-1').attr('disabled', false); 
});

 

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.