Forum Moderators: open
I have a problem with Ajax, PHP and mysql. I have a php page that has a form and the user can select with many checkboxes the options he desires. Then he clicks a button to fetch the different options in the database (going through Ajax). Now each options coming back from Ajax (after fetching the values in MySQL) have checkboxes. I tried to get access to the checkboxes returned by Ajax and it keep returning me 'null'. I gave them all dynamic ID in the id part and used the getElementById function but nothing works. Can you please help me?
Thank you
Second, don't dump your code. ;) Please review the posting guidelines [WebmasterWorld.com] and JS/AJAX Forum Charter [WebmasterWorld.com] before posting code.
The key here is -- relevant code.
Now each options coming back from Ajax (after fetching the values in MySQL) have checkboxes. I tried to get access to the checkboxes returned by Ajax and it keep returning me 'null'.
What do they look like when they come back, and how are you inserting these newly returned checkboxes on the page? Subsequently, how are you trying access these checkboxes?
If posting any code -- only post code relevant to those two questions first, as they are key to understanding your problem and the resolution thereof.
When the AJAX response is returned, you need to tell the "parent page" ... "We're baaaack!" by walking the response's DOM and handing its element identifiers back "up" to the script running in the "parent page".
Because this is wicked hard to explain without an example, I'll use an iframe example:
1) "Parent page" contains an iframe with "sub-page" loaded into it.
2) A link loads a new "sub-page" into the iframe.
How can the "parent page" get DOM information about the new page without being told? Well, the new page can reinitialize the script variables in use by the "parent page" as the new page loads, and then the "parent page" will know what to do.