Hi Folks, I need to add a "go to" box on a project I am working on.
The visitor comes to the site with a code. I need a box where they can enter that code and go directly to the correct article in the website. My php is poor, and I'm stuck. I may be going about this all wrong.
To test I have made a text doc called "list.txt" and populated it as follows:
Thank you so much for your reply, that works great, but I have a concern.
I may end up with 300 to 400 urls I need to reference. I thought by putting the references (with or without script) in an external file, that they would not get loaded with the page, and only loaded when the function was executed, I can now see this is not the case, and the external file is loaded with the page.
For a small number of references, thats fine, but with hundreds, that could be a problem.
Is there any way of loading the references "onclick" ?
***Edit to above post***
I've just tested Xelawho's script with 500 references. The increased size is about 20kb's and does not seem to impact the speed of the site, many thanks indeed
Last edited by cornishcharlie; 05-22-2012 at 06:21 AM.
Sine you have it working, the following would merely be an exercise for you to test out:
1- move the array into a PHP array on a different page on your web server.
2- code the page to accept the CODE as a URL parameter such that the only HTML that the page renders is either the URL or the words "Error - code not found".
3- change your current "checkValue" function to perform an AJAX call to the new page, passing the code as a URL parameter
4- when the AJAX requests returns with the result, if the response starts with "http" take the user to the new URL, otherwise show them the error message.
Bookmarks