By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,799 Members | 1,356 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,799 IT Pros & Developers. It's quick & easy.

Open a pdf by entering reference

P: n/a
Hi All,

We're in the process of re-writing the Intranet at work, and my javascript
knowledge could be written on the back of a post card. ;-)

Can any of you point me in the direction of some code that would enable a
form to open a specific pdf file? Details are below.

--------------------
All of our purchase orders are saved back to pdf files. Each pdf has the
prefix "PO_" followed by the po reference, then the file extension ".pdf".
For example, our file would be called "PO_12345M.pdf".
Each set of files is archived into years (folders are called 2003, 2004,
2005 etc.) so it will probably need a drop down box to select year, unless
it can search through all the folders.

The visitor should only need to enter the PO reference, and the code puts
the "PO_" and the ".pdf" on the end of it, and hey presto Acrobat opens with
the PO, or you get an error dialog if the file cannot be found.
--------------------

Any help appreciated, as is any code I can butcher to get this working.
Major brownie points this end. ;-)

Happy New Year everyone.

Horness
Jul 23 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"Horness" <sp**@abuse.net> wrote in message
news:34*************@individual.net...
Hi All,

We're in the process of re-writing the Intranet at work, and my javascript
knowledge could be written on the back of a post card. ;-)

Can any of you point me in the direction of some code that would enable a
form to open a specific pdf file? Details are below.

--------------------
All of our purchase orders are saved back to pdf files. Each pdf has the
prefix "PO_" followed by the po reference, then the file extension ".pdf".
For example, our file would be called "PO_12345M.pdf".
Each set of files is archived into years (folders are called 2003, 2004,
2005 etc.) so it will probably need a drop down box to select year, unless
it can search through all the folders.

The visitor should only need to enter the PO reference, and the code puts
the "PO_" and the ".pdf" on the end of it, and hey presto Acrobat opens with the PO, or you get an error dialog if the file cannot be found.
--------------------

Any help appreciated, as is any code I can butcher to get this working.
Major brownie points this end. ;-)

Happy New Year everyone.

Horness

Will this work for you? Watch for word-wrap.

This presumes that the "year" folders are under the folder that contains
this page.

The current year is the default and there is minimal validation.

Remove the "alert()" after testing.

<html>
<head>
<title>pdfinder.htm</title>
<script type="text/javascript">
function openPDF() {
var year = document.getElementById("Year").value;
var data = document.getElementById("Data").value;
if (data.length != 6) return;
var file = year + "\\PO_" + data + ".pdf";
alert(file); // remove after testing
window.open(file,"pdf","");
}
</script>
</head>
<body>
<form>
<select name="Year" id="year">
<option value="2005" selected>2005
<option value="2004">2004
<option value="2003">2003
</select>
<input type="text" name="Data" id=""Data" size="6" maxlength="6">
<input type="button" value="Open PDF" onclick="openPDF()">
<input type="reset" value="Reset">
</form>
</body>
</html>
Jul 23 '05 #2

P: n/a
That works perfectly, absolutely fantastic!

Many (MANY!) thanks for that - it's much appreciated.

<BIG GRIN>

Horness

"McKirahan" <Ne**@McKirahan.com> wrote in message
news:wu********************@comcast.com...
"Horness" <sp**@abuse.net> wrote in message
news:34*************@individual.net...
Hi All,

We're in the process of re-writing the Intranet at work, and my
javascript
knowledge could be written on the back of a post card. ;-)

Can any of you point me in the direction of some code that would enable a
form to open a specific pdf file? Details are below.

--------------------
All of our purchase orders are saved back to pdf files. Each pdf has the
prefix "PO_" followed by the po reference, then the file extension
".pdf".
For example, our file would be called "PO_12345M.pdf".
Each set of files is archived into years (folders are called 2003, 2004,
2005 etc.) so it will probably need a drop down box to select year,
unless
it can search through all the folders.

The visitor should only need to enter the PO reference, and the code puts
the "PO_" and the ".pdf" on the end of it, and hey presto Acrobat opens

with
the PO, or you get an error dialog if the file cannot be found.
--------------------

Any help appreciated, as is any code I can butcher to get this working.
Major brownie points this end. ;-)

Happy New Year everyone.

Horness

Will this work for you? Watch for word-wrap.

This presumes that the "year" folders are under the folder that contains
this page.

The current year is the default and there is minimal validation.

Remove the "alert()" after testing.

<html>
<head>
<title>pdfinder.htm</title>
<script type="text/javascript">
function openPDF() {
var year = document.getElementById("Year").value;
var data = document.getElementById("Data").value;
if (data.length != 6) return;
var file = year + "\\PO_" + data + ".pdf";
alert(file); // remove after testing
window.open(file,"pdf","");
}
</script>
</head>
<body>
<form>
<select name="Year" id="year">
<option value="2005" selected>2005
<option value="2004">2004
<option value="2003">2003
</select>
<input type="text" name="Data" id=""Data" size="6" maxlength="6">
<input type="button" value="Open PDF" onclick="openPDF()">
<input type="reset" value="Reset">
</form>
</body>
</html>

Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.