473,396 Members | 1,892 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,396 software developers and data experts.

AJAX: How to pass file names to a php script?

118 100+
Hi all,

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
  1. 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");
  2. var thisPic = 0;
  3. function doPrevious() {
  4.     if (document.images && thisPic > 0) {
  5.         thisPic--
  6.         document.baroque.src=pic[thisPic]
  7.     }
  8. }
  9.  
  10. function doNext() {
  11.     if (document.images && thisPic < 12) {
  12.         thisPic++
  13.         document.baroque.src=pic[thisPic]
  14.     }
  15. }
  16.  
Expand|Select|Wrap|Line Numbers
  1. <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
Nov 11 '07 #1
1 1500
acoder
16,027 Expert Mod 8TB
If I've understood you correctly, yes, it should be possible with Ajax. Pass the filename to the PHP script. The server-side script returns the comments in responseText or responseXML and you can either use it directly or parse it to get the comments. See an example.
Nov 12 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

31
by: Tony | last post by:
I just noticed that prototype.js is one of the files in the Ajax.NET distribution - I'm pretty concerned about this. Does anyone know if this is the same "prototype.js" that is not well-liked...
5
by: Ruso | last post by:
I am using ASP to make an application. What I want right now - is to make the self updating list of the users online - based on thier cookies. In my opinion all seems to be writen well with it's...
10
by: trpost | last post by:
I am using ajax / php where I am looking up some info from the database and populating a select list dynamically, however I am running into some sort of size limitation with the ajax.response...
21
by: Leena P | last post by:
i want to basically take some information for the product and let the user enter the the material required to make this product 1.first page test.php which takes product code and displays...
12
by: robin1983 | last post by:
hi everyone, i m very new to Ajax, and this is my first program in Ajax. I dont know what is wrong in the script. Please help me to find out the error, The main error is the value that i suppose to...
8
by: gearoid | last post by:
Hey I've designed an intranet site where users can upload documents (called 'resources') as part of a knowledge base. Part of the functionality of said site is that privilaged users can edit the...
8
by: sheldonlg | last post by:
I am still improving my AJAX and I ran into something that I'm not sure how to do. I will have a page called where I will have a dropdown list at the top and a large display at the bottom. The...
3
by: ToddFur | last post by:
I see several postings on this but I am still unable to figure out my problem. I can pass the values of my text field but not radio button (or even checkboxes). My PHP file <?php //declare...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.