Hello,
I've a question: is it possible to pass a variable from perl script to HTML form.
I want this variable $ztable value to be send to this form.
<input name="dirname" size=15> its post method form.
Thank you in advance.
Hello,
I've a question: is it possible to pass a variable from perl script to HTML form.
I want this variable $ztable value to be send to this form.
<input name="dirname" size=15> its post method form.
Thank you in advance.
As noted, if the HTML form is generated by your Perl script you can inject the value into the input element server‑side. Because upload_file.html is an external static file, the simplest, reliable approaches are: use a query string that the static page reads with client JavaScript; set a cookie from the Perl script and read it in the static page; or make upload_file.html dynamic (CGI/SSI/template) so the server can insert the value before sending the page.
A minimal, widely compatible pattern is to redirect to the static page with the value URL‑encoded, then let the page populate the field with JavaScript. Example Perl redirect (URL‑escape the value), then on upload_file.html use URLSearchParams to read dirname and set the input:
# Perl: send a Location header (URI::Escape recommended for encoding)
print "Location: /upload_file.html?dirname=$escaped_value\n\n"; <!-- upload_file.html: run this on load -->
<script>
var v = new URLSearchParams(window.location.search).get('dirname');
if (v) document.querySelector('input[name=\"dirname\"]').value = decodeURIComponent(v);
</script> If you prefer cookies (no query string visible), have the Perl script emit a Set-Cookie header and read document.cookie in the static page. Or rename the HTML to a CGI/template file and have the server insert the escaped value directly into the value attribute.
Security and robustness notes: always HTML‑escape values when inserting them into attributes (use CGI::escapeHTML or HTML::Entities::encode_entities), and percent‑escape values put into URLs (URI::Escape::uri_escape). Avoid putting untrusted data into page markup without escaping to prevent XSS. If cross‑page state must persist, consider sessions or a small server endpoint that returns the value as JSON and have the static page fetch it.
Jump to Post— Rashakil Fol 978Hello,
I've a question: is it possible to pass a variable from perl script to HTML form.
I want this variable $ztable value to be send to this form.
<input name="dirname" size=15> its post method form.Thank you in advance.
What is stopping you from something like
Hello,
I've a question: is it possible to pass a variable from perl script to HTML form.
I want this variable $ztable value to be send to this form.
<input name="dirname" size=15> its post method form.Thank you in advance.
What is stopping you from something like
print "<input name=\"dirname\" size=15 value=\"$ztable\">" (Assuming you've already replaced <, >, &, and " in $ztable with <, >, &, and ")
Hello,
Sorry, I was not able to put forward my question properly.
I mean i want to export this variables value to the external html form (upload_file.html)
which is under the menubar of this perl script.
This html-form is not inside the script it's external.
Any way?
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.