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

Question

Question

Form with JavaScript not saving field values on submitted form

asked on June 28, 2019

Good Day,

I have the following JavaScript to allow a variable to show on a table header:

$(document).ready(function () {
   
  $('.begindate input').change(function() {

    $('#q15 .cf-section-header h1').text('Week 1 Beginning '+$('.begindate input').val());
    $('#q40 .cf-section-header h1').text('Week 2 Beginning '+$('#q45 input').val());
  
 if ($('[name=IsLocked]').val() == 'True')
 {
    $('#q15 .cf-section-header h1').text('Week 1 Beginning '+$('.begindate.ro').text());
    $('#q40 .cf-section-header h1').text('Week 2 Beginning '+$('#q45.ro').text());
    }
  });
  
});

The calculated dates show on the subsequent approval forms when the JavaScript is adjusted to:

$(document).ready(function () {


    $('#q15 .cf-section-header h1').text('Week 1 Beginning '+$('.begindate input').val());
    $('#q40 .cf-section-header h1').text('Week 2 Beginning '+$('#q45 input').val());
  
}); 

However, if the form is rejected back to the initiator the variables do not display on the form. In addition, once the form is submitted into Laserfiche the fields show up as undefined. I have seen in other posts that this happens because coverts the data to read-only, and I altered to code to fix this issue, but I have not been successful. 'begindate' is date field as well as '#q45'.

Any ideas on what needs to be adjusted?

0 0

Replies

replied on June 28, 2019

Any changes made with javascript while the form is being filled out (IE on change), except entering a value into a field, will be removed before saving to the repository.

If you enter any code to run on document ready, it will re-run that code, that is why you saw the undefined.

The reason it was undefined is because all inputs, selects, and other types are changed to divs. You must treat them as divs. Also the innerHTML of the div will contain the value twice (IE: hello world would become helloworldhello world)

This is what I have discovered so far through trial and error, no official information has been released yet.

0 0
replied on June 28, 2019

Thanks Chad! Will the input be rewritten as $('div#q45').text() and $('div.begindate45').text()?

0 0
replied on May 19, 2020

Hi Simon,

I am also facing similar issue.

In my case there is radio button , one hidden table and a field.

There is a java script code on click of radio button it will take a value from a field and it will first show the hidden table and replace table label with that field value.

Its working properly till i submit the form, after submitting when i check the form in completed task tab. To see the hidden table when i click the radio button, its not taking any value from that field instead of value its display the value as "Undefined" to that table label.

So can you please assist.

 

Thank you,

Sudesh Singh.

0 0
replied on May 20, 2020

Hi Sudesh,

Unfortunately, I was not able to solve this riddle. I did reach out to presales and they provided some insight on what to do,  and I tried a few combinations but was never able to get the actual value to display.

Thanks,

Simon

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

Sign in to reply to this post.