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

Discussion

Discussion

Javascript filled forms not saving

posted on November 15, 2016

I have a similar problem to this but I have some relational Javascript that fills out just fine in the form but then on Submit it doesn't get saved. Other parts of the Javascript work, just this one doesn't. I have a lot of calculations that are using Javascript so I will only post the part that doesn't work, let me know if you need the whole thing:

Some Data pulls from our SQL database, then I manipulate it, like the type, but I want to set a field to something that makes more sense "translate it":

//Determine if Online or On-Ground course
	$(".type input").change(function(){
    var type = $(".type input").val(); 

    if (type == "ONLN"){
      $(".subtype input").val("Online");
      }
    else if (type == "LEC"){
      $(".subtype input").val("On-ground");
      }
  });  

So here is another piece of code that populates when filling out, but disappears when Submitted:

//Assign Assignor & Address
	$(".type").change(function(){
    var type = $(".type input").val();

    if (type == "ONLN"){
      $(".assignor input").val("Jane Doe");
      $(".titleassi input").val("Dean of Online Education");
      }
    else if (type == "LEC"){
      $(".assignor input").val("John Smith");
      $(".titleassi input").val("Dean of AGS Operations");
      }
  });  

Please help!

1 0
replied on November 16, 2016

Are the fields you use JavaScript to fill set to Read-only when design form? For read-only fields, the values set by JavaScript won't be respected when process in the backend. If that is the case, you can set the fields to read-only using JavaScript instead of set them through Forms designer.

2 0
replied on November 16, 2016

I think they are that is probably the case! But I have other fields that get filled out with javascript that are also readonly by design and somehow they work, pretty strange!

0 0
replied on November 16, 2016

What the field type for those fields that works? And can you give sample for how the JavaScript set those value?

0 0
replied on November 18, 2016

All fields involved (ones that works and others that do not) are Single Line. You were right - removing the "read-only" from the fields made the values stick!

 

Here is an example of code that works, but you were right, it was the Read Only attribute that was causing issues. 

//Campus location
	$(".tcampus input").change(function(){
    var tcampus = $(".tcampus input").val();
    var type = $(".type input").val();

    if (tcampus == "O000000001" && type == "ONLN"){
      $(".campus input").val("Online");
      }
    else if (tcampus == "O000000001"){
      $(".campus input").val("Bartlesville, OK");
      }
    else if (tcampus == "O000000016"){
      $(".campus input").val("Tulsa, OK");
}
  });

Do you by any chance know the javascript code on top of your code for read only attribute? :) if not, I will surely look it up but I just wondered if you knew.

 

Thanks so much for your help!!!

1 0
replied on November 22, 2016

You can use

$('.campus input').attr('readyonly',true);

or 

$('.campus input').prop('readyonly',true);

 

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

Sign in to reply to this post.