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

Question

Question

Can Someone Help? Trying to Set Value of Req. # to PO # Field

asked on January 18, 2019

I've spent too much time trying to get this to work. When I reject something, if the poNo field is empty, I'd like to put the value of the reqNo field into the poNo field, but I haven't gotten it to work yet! Here's my code:

$(document).ready(function(){

//Set PR # if PO # is blank and make comments required when voiding, removing required fields
  $('.Reject').click(function() {    
    $('.lfProcessTask input').val('Final PO Package');
    var reqNoInput = $('.reqNo input').val(); //Get value of Req. No.
    var poNoInput = $('.poNo input').val(); //Get value of PO No.
    if(poNoInput.val() == '') //If there's no PO #
    {
      poNoInput.val(reqNoInput); //Use the PR # as the PO #
    }
    else if($('#comments').val() == '')
    {
       alert('Please enter VOID details into the Comments box before selecting this action');
       return false;
    }
    $('*[required]').each(function() { 
      $(this).removeClass('required')
      $(this).removeAttr('required');
    }); 
  });

});  //close document ready

Fresh eyes would be great!

0 0

Answer

SELECTED ANSWER
replied on January 20, 2019

I figured it out. The form following this task had the target field as "read only". I removed it and it now works! Darn, that gets me every time!

0 0

Replies

replied on January 18, 2019

Use

$('.poNo input').val(reqNoInput); //Use the PR # as the PO #

instead of

poNoInput.val(reqNoInput); //Use the PR # as the PO #

 

0 0
replied on January 18, 2019

Thanks … didn't work.

$(document).ready(function(){

//Set PR # if PO # is blank and make comments required when voiding, removing required fields
  $('.Reject').click(function() {    
    $('.lfProcessTask input').val('Final PO Package');
    var reqNoInput = $('.reqNo input').val(); //Get value of Req. No.
    var poNoInput = $('.poNo input').val(); //Get value of PO No.
    if(poNoInput.val() == '') //If there's no PO #
    {
      $('.poNo input').val(reqNoInput); //Use the PR # as the PO #
    }
    else if($('#comments').val() == '')
    {
       alert('Please enter VOID details into the Comments box before selecting this action');
       return false;
    }
    $('*[required]').each(function() { 
      $(this).removeClass('required')
      $(this).removeAttr('required');
    }); 
  });

});  //close document ready

 

0 0
replied on January 18, 2019 Show version history

You're missing a semicolon at the end of line 18. You also have .val() after the poNoInput in your if statement, that i don't think is necessary since it is a var you created from above.

$(document).ready(function(){

//Set PR # if PO # is blank and make comments required when voiding, removing required fields
  $('.Reject').click(function() {    
    $('.lfProcessTask input').val('Final PO Package');
    var reqNoInput = $('.reqNo input').val(); //Get value of Req. No.
    var poNoInput = $('.poNo input').val(); //Get value of PO No.
    if(poNoInput == '') //If there's no PO #
    {
      $('.poNo input').val(reqNoInput); //Use the PR # as the PO #
    }
    else if($('#comments').val() == '')
    {
       alert('Please enter VOID details into the Comments box before selecting this action');
       return false;
    }
    $('*[required]').each(function() { 
      $(this).removeClass('required');
      $(this).removeAttr('required');
    }); 
  });

});//close document ready

Try that ^^ 

0 0
replied on January 18, 2019

@████████ When you preview the form, you can look for errors by pressing F12 and clicking on the Console tab. Those errors could help us troubleshoot a little better.

0 0
SELECTED ANSWER
replied on January 20, 2019

I figured it out. The form following this task had the target field as "read only". I removed it and it now works! Darn, that gets me every time!

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

Sign in to reply to this post.