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

Question

Question

insert picture in a form

asked on January 5, 2017 Show version history

I follow the instructions on this question: http://answers.laserfiche.com/questions/110714/how-to-insert-a-picture-in-a-form-on-forms#repliesToMain,

It works at the begining, but when I insert more code to the JS, the picture does not appear anymore, what could be the problem,

 

my complete code is:

 

$(document).ready(function () {

    var iml = ['jpg','jpeg','gif','png'];

    $('.files tbody tr').each(function() {

      if ($(this).find('a').length && $.inArray($(this).find('a').attr('title').match(/\.(\w{3,4})$/)[1],iml)>-1) {

        var ims = $(this).find('a').attr('href'),

            imr = $('<img style="width:300px;" />');

        imr.attr('src',ims);

        $('<tr><td colspan=3>'+imr.prop('outerHTML')+'</td></tr>').insertAfter($(this).find('a').closest('tr'));

      }

    });

});
 

$(document).ready(function(){
  
    $('#q80').hide();
     $('.tab1').on('click',showPre);
      $('.tab2').on('click',showExpe);
});
  
function showExpe(){
      $('.tab1').removeClass('selected');
    $('.tab2').addClass('selected');
    $('.Pre').hide();
      $('.Expe').show();
}

function showPre(){
      $('.tab1').addClass('selected');
      $('.tab2').removeClass('selected');
    $('.Pre').show();
      $('.Expe').hide();
}

$(document).ready(function () {
$('.Submit').hide(); //hide the submit button by default
  
  $('.signSignatureBtn').click(function () {
    $('.Submit').show(); //show the submit button after signing
 });
 
  $(document).on('click','.form-sig-remove',function(){

    $('.Submit').hide(); //hide the submit button if the signature is removed
  });

});

 

 

0 0

Replies

replied on January 6, 2017

Hello,

Might it be caused by line $('#q80').hide(); ? If your image field has id q80, your image reappear once you remove that line. Thank you

0 0
replied on January 6, 2017

The field has ID "q26", I try to remove that line but the result was the same.

 

 

0 0
replied on January 12, 2017

Sorry for the late reply. 

Correct me if I misunderstand, but do you want to show picture (like preview) on the form as you upload picture to the form? Or do you want to show pictures on submitted form? Thank you

0 0
replied on January 12, 2017

Our customer wants to see the picture embedded in the form on the repository,  for candidate selection process. 

Also to have a preview on the form submition for the candidate to see that is ok. 

The code we were using Works for some time, but  it doesn't work anymore,  we try to replicate the code on a New form and on a New test installation but aparently something is missing. 

Thanks for the help 

0 0
replied on January 12, 2017

Hello,

Can you please check if you have any error messages on developer console? You can open the developer console with F12 key. Maybe refresh the page to check if your javascript is causing any errors. 

Thank you.

0 0
replied on January 12, 2017

Aparently no errors are showing but the code still does not work. I attach the test form, A clean form in a fresh install server, I am using for testing in XML - txt format, to see if you can find whats wrong with the process.

 

 

0 0
replied on January 13, 2017

Hello,

I assume that you are saving your form as pdf file in the repository. Can you please test with the following code? 

$(document).ready(function () {
    var iml = ['jpg','jpeg','gif','png'];
    $('.files tbody tr').each(function() {
      if ($(this).find('span').length && $.inArray($(this).find('span').text().match(/\.(\w{3,4})$/)[1],iml)>-1) {
        var ims = $(this).find('span').attr('href'),
            imr = $('<img style="width:300px;" />');
        imr.attr('src',ims);
        $('<tr><td colspan=3>'+imr.prop('outerHTML')+'</td></tr>').insertAfter($(this).find('span').closest('tr'));
      }
    });
});

Thank you

1 0
replied on January 13, 2017

The code above is slightly updated.

0 0
replied on January 13, 2017 Show version history

Ill try the code, but still doesnt work, nor the preview form or the pdf file or the repository has the picture.

 

Thanks again.

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

Sign in to reply to this post.