How can I pass parameters to a function within a Blank application?

Hello,

I am trying to incorporate ViewerJS in my project to visualize images stored on my server. I have the code working in a blank HTML application, but at this moment in the code I have the name of an image file in a fixed way. I need the name of the image file to change dynamically based on the value contained in the field inside a form. How can I pass a parameter from my form to the javascript function within the Blank HTML application?
Thank you,

(I hope you can understand me, I speak little English)

This is the code of my blank HTML application.

?>
<!DOCTYPE html>
<html lang=“en”>
<head>
<meta charset=“utf-8”>
<meta http-equiv=“x-ua-compatible” content=“ie=edge”>
<meta name=“viewport” content=“width=device-width, initial-scale=1, shrink-to-fit=no”>
<title>Viewer.js</title>
<link rel=“stylesheet” href=“https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css”>
<link rel=“stylesheet” href="…/…/…/viewerjs/dist/viewer.css">
</head>
<body>
<div class=“container”>
<!–<h1>Documento de identificacion</h1>–>
<button type=“button” class=“btn btn-primary” id=“button”>
Ver
</button>
</div>

<script src=“https://code.jquery.com/jquery-3.3.1.slim.min.js”></script>
<script src=“https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.bundle.min.js”></script>
<script src="…/…/…/viewerjs/dist/viewer.js"></script>
<script>
window.addEventListener(‘DOMContentLoaded’, function () {
document.getElementById(‘button’).addEventListener(‘click’, function () {
var image = new Image();
image.src = ‘…/…/…/viewerjs/docs/images/65941-.jpg’;
var viewer = new Viewer(image, {
hidden: function () {
viewer.destroy();
},
});
// image.click();
viewer.show();
});
});
</script>
</body>
</html>
<?

How about passing the value via a global variable.
You can do this using a Scriptcase link or the URL to call the app.

Then you change the code of your script a little bit.
Assuming the global variable is named
image_file_name
you could change the line:

image.src = '../../../viewerjs/docs/images/65941-.jpg';

into:

image.src = '../../../viewerjs/docs/images/<?php echo [image_file_name];?>';

This should insert the value into the script.

Hope this will help you.

Sincerely
Gunter Eibl
(Germany)
scriptcase.coach
email@GunterEibl.de