0

I'm currently defining multiple global JS vars in a PHP foreach within a div this way:

<script>
    var signaturePad<?= $i ?>;
</script>

Output:

var signaturePadYWduZFlQVm9xS1dhNDJYYU1ZdCtWUT09;

I need to do this because I later need to get some content from the global var depending on the shown div.

Now I've the problem that I don't know how I can use the generated variable in JS. I've tried it this way but this can't work:

var targetId = jQuery(this).attr('data-target-id'); //The id after signaturePad....
signaturePad + targetId = new SignaturePad();

Later I need to get for example a signature from the object:

signaturePad + targetId.toDataURL('image/png')

Any idea how I can deal with this?

Mr. Jo
  • 4,946
  • 6
  • 41
  • 100

0 Answers0