PDA

View Full Version : Div / iFrame dilemma



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.

tacticious
09-19-2008, 04:55 PM
Okay, sorry for the double post...

It seems my question is a really dumb question, otherwise I think I'd have gotten some answers by now. So, that said, I'm changing my question.

Does someone have any suggestions on how to accomplish this?

I have three fields: Subnet, VLan, and Description. The script will echo out all the records, displaying all the information. Upon clicking the Subnet, I'd like for the user to be able to edit the value of this without reloading the page (there are going to be a large quantity of records, reloading the page will be a burden to the user and inefficient). The same goes for VLan, and Description. Upon clicking the value, the user can edit the value, the value will be updated in the (MySQL) Database, and the new value will replace the edit box.

The reason I have went with an iframe originally was because I could not figure out how to send POST data (I'd like for it to be POST, so that the 'Description' field can have line breaks and such) without reloading the page. I need to have a form (with one editable textbox or textarea) that the user will edit and input the future value of the field into.

So, again, my question: Does anyone have a suggestion - be it a resource, code snippet, article, website, function, or whatever - on how to accomplish this? Don't get me wrong; The PHP script is done. I'm simply asking for suggestions regarding the Javascript portion, so I can edit values without reloading the page.

Any help would be greatly appreciated.