I’m creating a page with an array of data (a list of products part numbers).
Everything only with Javascript. I don’t know php, or other languages, and the page must work standalone, since I can’t put code on the server, but only in a local folder.
I’m trying to create a "dynamic" url in order to click on the code and open its drawing.
The problem is that the part number is known, but the drawing can have a revision number, or not have anything, but I don’t know it before. The array is updated externally when a new revision number is applied.
Example:
p/n: 1234 –> drawing: 1234.pdf (but after a certain period, this p/n can receive a revision and become 1234 Rev.1.pdf)
p/n: 5678 –> drawing: 5678 Rev.1.pdf (but after a certain period, this p/n can receive a revision and become 5678 Rev.2.pdf)
What I’m trying to do (with no success until now, and I’m not finding anything useful in the previous posts) is to pass an url that has a fixed part (the p/n) and a variable part that can exist or not.
Something like "partnumber*.pdf"
Is it possible to do this?
My array of data is:
regrf=new Array();
regrf[0]=new Array("1234","Product1");
regrf[1]=new Array("5678","Product2");
The script that uses the array is:
document.write("<a href="+regrf[n][0]+".pdf"><img src='images/drawing.png'></a>");
What I want to get is a list like this:
- 1234 linked to "1234*.pdf"
- 5678 linked to "5678*.pdf"
- …
So that when "1234.pdf" becomes "1234 Rev.1.pdf", or "5678 Rev.1.pdf" becomes "5678 Rev.2.pdf" I don’t have to update the destination url manually.
Thanks to anyone who will help
2
Answers
I understand what you’re trying to do, but I’ll need to understand what you mean by you can only put code in a local folder.
It seems to me that the solution to your problem is reading the actual file names of all the PDFs. Say you had a PDF called
1234.Rev.1.pdf
, you could read the p/n from the file.The issue is that outside of a server environment, you can’t read filenames inside a folder.
I’d love to help you out, let me know more about your code. You can use NodeJS to give you a list of all filenames using the fs module. There are many simpler ways to solve this but it may require some major changes to your project.
OLE object linking can only alter the embed to the current linked object not a wildcard, and there are no inbuilt incremental variables, but you could write your own.
You cannot use links to file objects that were not there at the time. For an excel listing the simplest is import a c,s,v listing of current files. those that are deleted will simply not be accessible, at that time, then you need to reimport the list.
By far the simplest method for a known set of variations is update to the current range. And for todays/this minute file sets from a folder that’s usually via DIR.
If the change is constant you need a folder monitor that re-writes the list constantly. If it is at start of day you simply need the server to run a knightly command line task.