Developing a school website in WordPress and need to upload Progress Report of students in the server in pdf format. File name of Progress report will be the Admission number of the students (Eg. 123.pdf). When students enter their Admission number in the input box, they should get their progress report file downloaded. As of now using below form box to redirect to file url.
<script>
function process()
{
var url="http://demo.websign.in/" +
document.getElementById("url").value;
location.href=url;
return false;
}
</script>
<form onSubmit="return process();">
ENTER YOUR ADMISSION NUMBER: <input type="text" name="url" id="url">
<input type="submit" value="DOWNLOAD">
</form>
Any help as I am a theme developer and no much knowledge in coding?
You do not need form tag to download file. Also instead of type "submit" use "button". The js you need is something like this:
function myFunction()
{
var downloadUrl = document.getElementById("url").value;
document.getElementById("downlod").href = downloadUrl + '.pdf';
}
<div>
<label>ENTER YOUR ADMISSION NUMBER:</label> <input type="text" name="url" id="url" onkeypress="myFunction()">
<a href="foo" id="downlod" download><span>Download</span></a>
</div>
</div>