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

Question

Question

Works with Preview Mode but not when I run it!

asked on July 18, 2018 Show version history

Transmittal is a an upload field (only allows one PDF).

transCopy provides the name of the uploaded file.

Subfolder takes the .pdf off at the end.

$(document).ready(function(){

//When Transmittal Upload Changes
  $('.transmittal').change(function(){

    document.getElementById('Field15').value = '';
    var attment = $('.ellipsis').attr('title');

      document.getElementById('Field15').value = attment;

    var fileName = document.getElementById('Field15').value;
    fileName = fileName.substring(0, fileName.indexOf('.'));

      document.getElementById('Field14').value = fileName;

  });

})  //close document.ready

While getting this to work, continued to use Preview Mode ... worked great!

Here's my issue. It doesn't work in practice!!!!

Why not? Using Laserfiche Forms Professional Version 10.2.1.246.

0 0

Answer

SELECTED ANSWER
replied on July 20, 2018 Show version history

I don't believe in " throwing in the white flag", So put the event listen on the submit button. 

 $('.Approve').click(function() {
     document.getElementById('Field1').value = '';
     var attment = $('.ellipsis').attr('title');
     
        document.getElementById('Field1').value = attment;
     
     var fileName = document.getElementById('Field1').value;
     fileName = fileName.substring(0, fileName.indexOf('.'));
     document.getElementById('Field3').value = fileName;

//Just for testing can remove later
            alert('Attachement file name is: ' +fileName );
     
        });

So on my form the button was approved, if you have a submit button please change .Approve to .Submit. I also tested it for when you drag a picture, works like a charm.

2 0

Replies

replied on July 19, 2018 Show version history

Hi Gloria 

Tested the code as well it doesn't work, Please see the code below that works.

$('.upload ').on('blur', 'input', getName); 
  
  function getName(){
     document.getElementById('Field1').value = '';
     var attment = $('.ellipsis').attr('title');
     
        document.getElementById('Field1').value = attment;
     
     var fileName = document.getElementById('Field1').value;
     fileName = fileName.substring(0, fileName.indexOf('.'));
     document.getElementById('Field3').value = fileName;
  
  	
  }

So instead of change, I tried it with blur and it seems to work.

Please let me know if it works.

1 0
replied on July 19, 2018 Show version history

I get "undefined" for Field1 and nothing for Field3 ... and that's with Preview and running the process.

0 0
replied on July 19, 2018

Please post your code

1 0
replied on July 19, 2018 Show version history

fields 1 and 3 in sample code need to be changed to match your fields 14 and 15

1 0
replied on July 19, 2018

Update, it almost works! I initially get "undefined", however, if I click once more on the screen, it fills in the values I'm looking for. Here's my code:

$(document).ready(function(){

//When Transmittal Upload Changes
  $('.transmittal').on('blur', 'input', getName); 
  function getName(){
    document.getElementById('Field15').value = '';
    var attment = $('.ellipsis').attr('title');

      document.getElementById('Field15').value = attment;

    var fileName = document.getElementById('Field15').value;
    fileName = fileName.substring(0, fileName.indexOf('.'));

      document.getElementById('Field14').value = fileName;

  }

})  //close document.ready

 

Initially, I see:

But if I click anywhere on the screen, I get:

0 0
replied on July 19, 2018

That's how blur works, As soon as you do something else it runs the JS code. So if the person click's on submit it will get the name of the attachment before submitting. 

0 0
replied on July 19, 2018 Show version history

OK, to help support that, I created a "final" form that saves the variables for the Save to Laserfiche task. Works fine when I click the upload button to add my files, but doesn't work when I drag and drop the file(s) because I'm not clicking on anything else. SO CLOSE!

0 0
replied on July 19, 2018

The ultimate goal was to create a folder within Laserfiche named the same name as the transmittal being uploaded (without the .pdf at the end). That being said, it's a temporary folder, so leaving the .pdf there as part of the folder name is no big deal. Having too much trouble getting the right solution to work for such a minor problem. @████████, you have been totally amazing staying with me this far, but I'm throwing in the white flag. Thank you!

0 0
SELECTED ANSWER
replied on July 20, 2018 Show version history

I don't believe in " throwing in the white flag", So put the event listen on the submit button. 

 $('.Approve').click(function() {
     document.getElementById('Field1').value = '';
     var attment = $('.ellipsis').attr('title');
     
        document.getElementById('Field1').value = attment;
     
     var fileName = document.getElementById('Field1').value;
     fileName = fileName.substring(0, fileName.indexOf('.'));
     document.getElementById('Field3').value = fileName;

//Just for testing can remove later
            alert('Attachement file name is: ' +fileName );
     
        });

So on my form the button was approved, if you have a submit button please change .Approve to .Submit. I also tested it for when you drag a picture, works like a charm.

2 0
replied on July 20, 2018

I stand by my original comment ... you are brilliant! Thanks so much for your persistence! It did work like a charm! smiley

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

Sign in to reply to this post.