473,385 Members | 1,602 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Open a pdf by entering reference

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
2 1485
"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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: J.R | last post by:
I'm trying to determine if a named child window has been opened before opening a new one, however my challenge is that the child window may have been opened from a parent that no longer exists,...
2
by: Raptor | last post by:
I'm a complete Javascript n00b, using a snippet I found on the web. I'll probably be buying a Javascript book. What's the authoritative on-line resource for Javascript, like php.net is for PHP? ...
1
by: Horness | last post by:
McKirahan was kind enough to help me out with some code to open PDF's by entering the reference number contained in the file name. Many thanks for that (we've adapted it to work with other files...
2
by: Julia Baresch | last post by:
Hi everyone, As some of you may know, we've been having trouble with an unrecognized database format error. Today I installed an unfinished project on the workstation of one of my users. ...
15
by: Dave | last post by:
Has anyone encountered the error message "Can not open any more databases" and what did you do to solve it? Thanks, Dave
4
by: redryderridesagain | last post by:
My macro is writing to a table(T) and reading a query (Q) based on that table (VBA/Visual Basic 6.3). I cannot write T and read Q in the same execution of the macro, however, if I skip the writing...
5
by: blue | last post by:
We often get connection pooling errors saying that there are no available connections in the pool. I think the problem is that we are passing around open readers all over the place. I am...
1
by: Savas Ates | last post by:
i was given an url bla bla.wsdl i am asked for entering data using this wsdl url? is it possible? how can i do it? must i use asp.net werb services .. any url or example or way t solve it...
13
by: Seth Grimes | last post by:
Hello all, I want to open a window when a user leaves my site. I set up a function called by onUnload. To skip the window.open if the user hasn't left my site, I set a variable in my links and...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.