I have a photography page on my website, I have pictures on the page (obviously) but the file names are stored and loaded in Javascript, in an array.
Expand|Select|Wrap|Line Numbers
- var pic = new Array("./images/under1[1].png","./images/anemon.png","./images/arrow.png", "./images/babymoray.png","./images/grouper.png","./images/meridian.png", "./images/grouper1.png","./images/moray.png", "./images/morayeel.png", "./images/toitle.png", "./images/triggerfish.png", "./images/wreck.png", "./images/end.png");
- var thisPic = 0;
- function doPrevious() {
- if (document.images && thisPic > 0) {
- thisPic--
- document.baroque.src=pic[thisPic]
- }
- }
- function doNext() {
- if (document.images && thisPic < 12) {
- thisPic++
- document.baroque.src=pic[thisPic]
- }
- }
Expand|Select|Wrap|Line Numbers
- <img style="border-color:#000000;" name="baroque" src="./images/under1[1].png" usemap="#thismap"><map id="thismap" name="thismap"> <area shape="rect" coords="40,15,85,25" href="javascript:doPrevious()" alt="previous" target="_parent"><area shape="rect" coords="460,15,490,25" href="javascript:doNext()" alt="next" target="_parent"><area shape="rect" coords="295,195,320,205" href="javascript:history.back(-1)" alt="back" target="_parent"></map>
I have set up a MySQL database to hold: the filename, username, email address and the comment. So when a user posts a comment it posts it to the database then pulls it from the database and enters it into a div on the page. Where people can read it.
The only problem is that the file names are stored using Javascript, so when the 'Next' button (doNext() function) is pressed/called the filename changes. But to load the comments I need to use PHP.
(Hope that made sense so far) Is there a way to pass the filenames, from the javascript to a php script in order to load the relevant comments?
Is this possible with ajax? Or, if not, can anyone suggest another way of storing the comments, perhaps XML?
Thanks,
Sam