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

Question

Question

Input Form Field not saving on submit?

asked on February 15, 2018 Show version history

I am already aware that the input fields should be transferred to read-only in order to show up on submit per this post: https://answers.laserfiche.com/questions/122818/CSS-not-saving-to-laserfiche 

The question is where do I insert  the code to make my inputs read-only?

 if ($('[name=IsLocked]').val() == 'True')

 

Here is some of my code, on Purpose selection (change), account is being populated with a certain value:

//Sub Account is filled out based on Purpose selection
  $(".purpose select").change(function(){
    var purpose = $(".purpose select").val();

    if (purpose == "Adjunct Pay") {
      $(".account input").val("123");
    }
    else if (purpose == "Cross Training") {
      $(".account input").val("1234");
    }
    else if (purpose == "Curriculum Development") {
      $(".account input").val("234");
    }
    else if (purpose == "Full-time Faculty Overload") {
      $(".account input").val("321");
    }
    else if (purpose == "Change to regular salary/wage rate") {
      $(".subaccdisp input").hide();
    }
  });
  

 

0 0

Answer

SELECTED ANSWER
replied on February 21, 2018

Hi Lidija,

First I want to clarify something: is your "account" field read-only? If not, the value you filled on this field could be submitted so you don't need to handle the case with displaying value on a read-only form.

If your field is read-only, custom script filled value would not be submitted then you will need the script to make it looking like filled, but actually the variable value is still the default one. In this case, I would suggest using Formula instead to populate the field values so the values could be submitted. The Formula should be set on the account field and like =IF(Purpose="Adjunct Pay", "123", IF(Purpose="Cross Training", "1234", ""))

But if your logic is more complicated or you need to do more than filling field, the script is like this (add this below your script sample):


  if ($('[name=IsLocked]').val() == 'True') {
    var purpose = $(".purpose .ro").text();
    if (purpose == "Adjunct Pay") {
      $(".account .ro").text("123");
    }
    if (purpose == "Cross Training") {
      $(".account .ro").text("1234");
    }
  }

 

1 0
replied on February 22, 2018

Thank you Rui! That makes a lot of sense. My javascript is a bit more complex than the example, but for anyone wondering, here is the full javascript code with Rui's read-only script:

$( document ).ready(function() {
//Sub Account is filled out based on Purpose selection
  $(".purpose select").change(function(){
    var purpose = $(".purpose select").val();

    if (purpose == "Adjunct Pay") {
      $(".account input").val("123");
    }
    else if (purpose == "Cross Training") {
      $(".account input").val("1234");
    }
  });
    
if ($('[name=IsLocked]').val() == 'True') {
  var purpose = $(".purpose .ro").text();
      
  if (purpose == "Adjunct Pay") {
    $(".account .ro").text("123");
  }
  if (purpose == "Cross Training") {
    $(".account .ro").text("1234");
  	}
  }
  
});

 

0 0

Replies

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

Sign in to reply to this post.