tacticious
09-16-2008, 07:26 PM
I have a script (PHP) which shows a large (potentially huge) list of data. I need to edit bits of the information without reloading the page. I've turned to AJAX for this, which is working to edit it just fine. I currently have each field in a div, which upon clicking populates the div with an iFrame, the iFrame is a page that edits the information. Once the user submits the information, it saves to the database just fine. My only situation is now I need to repopulate the div with just the field's data, not the iFrame. How could I go about doing this? I've tried putting a javascript function in the onload of the iFrame's <body> tag which will change the div's content to its original state, which I cannot get to work. There are no javascript errors, the same script works fine in the main page (not the iFrame) so I assume I've got to define the div differently in the script when it's being called by the iFrame. If that's the case, what am I missing? Here's my code:
The following is being called by the iFrame, not currently working:
function PopulateDiv( data, div ){
if( div !='' ){
var objMyDiv = document.getElementById( div );
objMyDiv.innerHTML = data;
}
return;
}
Is there a better way to go about this? I couldn't find a way to send POST data without refreshing the page other than using an iFrame. I'm not particularly focused on using an iFrame, if there's an alternative that's easier/more functional I'll use it.
Anyway, help would be appreciated. I hope I explained it well enough.
The following is being called by the iFrame, not currently working:
function PopulateDiv( data, div ){
if( div !='' ){
var objMyDiv = document.getElementById( div );
objMyDiv.innerHTML = data;
}
return;
}
Is there a better way to go about this? I couldn't find a way to send POST data without refreshing the page other than using an iFrame. I'm not particularly focused on using an iFrame, if there's an alternative that's easier/more functional I'll use it.
Anyway, help would be appreciated. I hope I explained it well enough.