Open a pdf by entering reference

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Horness

    #1

    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


  • McKirahan

    #2
    Re: Open a pdf by entering reference

    "Horness" <spam@abuse.net > wrote in message
    news:34hqhgF4c8 udjU1@individua l.net...[color=blue]
    > 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[/color]
    with[color=blue]
    > 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[/color]


    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.getEle mentById("Year" ).value;
    var data = document.getEle mentById("Data" ).value;
    if (data.length != 6) return;
    var file = year + "\\PO_" + data + ".pdf";
    alert(file); // remove after testing
    window.open(fil e,"pdf","");
    }
    </script>
    </head>
    <body>
    <form>
    <select name="Year" id="year">
    <option value="2005" selected>2005
    <option value="2004">20 04
    <option value="2003">20 03
    </select>
    <input type="text" name="Data" id=""Data" size="6" maxlength="6">
    <input type="button" value="Open PDF" onclick="openPD F()">
    <input type="reset" value="Reset">
    </form>
    </body>
    </html>


    Comment

    • Horness

      #3
      Re: Open a pdf by entering reference

      That works perfectly, absolutely fantastic!

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

      <BIG GRIN>

      Horness



      "McKirahan" <News@McKirahan .com> wrote in message
      news:wu-dne7hvpkTXH7cRV n-ig@comcast.com. ..[color=blue]
      > "Horness" <spam@abuse.net > wrote in message
      > news:34hqhgF4c8 udjU1@individua l.net...[color=green]
      >> 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[/color]
      > with[color=green]
      >> 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[/color]
      >
      >
      > 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.getEle mentById("Year" ).value;
      > var data = document.getEle mentById("Data" ).value;
      > if (data.length != 6) return;
      > var file = year + "\\PO_" + data + ".pdf";
      > alert(file); // remove after testing
      > window.open(fil e,"pdf","");
      > }
      > </script>
      > </head>
      > <body>
      > <form>
      > <select name="Year" id="year">
      > <option value="2005" selected>2005
      > <option value="2004">20 04
      > <option value="2003">20 03
      > </select>
      > <input type="text" name="Data" id=""Data" size="6" maxlength="6">
      > <input type="button" value="Open PDF" onclick="openPD F()">
      > <input type="reset" value="Reset">
      > </form>
      > </body>
      > </html>
      >
      >[/color]


      Comment

      Working...