|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Can Parent Form Submit Button post IFrame Form Data?
There must be a way to do this, but it is beyond my JS understanding.
I have an .asp parent with an embedded Iframe file. The Iframe file consists of a simple form that collects user data for database storage on form submit. I'm OK with all of that... the problem is that the Submit button is in the parent file (not in the Iframe file), and is used first to call the form file into the Iframe, and then I want that same Submit button in the parent file to post the form data out of the Iframe file. I haven't been able to figure out how to specify the Iframe form ID, since the parent file wants to submit the parent form (the one that calls the Iframe form in the first place), rather than the called Iframe form containing user data. Hmmm. Any guidance would be appreciated. |
|
#2
|
||||
|
||||
|
What's the purpose of the iframe at all? Seems kind of pointless.
Unless there's a purpose, you might be better using an ASP include statement to embed the fields into your main ASP page. There might be ways with hidden fields on your parent page and a whole pile of javascript to pull DOM from the iframe... but honestly, it's overkill... I wouldn't mind seeing an example of a page, to have a better idea of what you're trying to accomplish.
__________________
Daryl's Homepage | My Blogroll | My Profile | Firefox supporter! DevArticles Forum Moderator "The net is a waste of time, and that's exactly what's right about it." -- William Gibson |
|
#3
|
|||
|
|||
|
Quote:
The purpose of the iframe is to hold changeable content. It begins at parent onload with a listing of selected database records displayed in file1.asp. On form submit, the iframe changes to file2.asp, a data input form to collect user info. Then, on form submit, that form data is written to a db and file1.asp is reloaded into the iframe, now displaying the updated records listing. It turns out that the problem of triggering a form submit for a form contained in an iframe from a submit button contained in the parent can be handled by a single line of code in a function called by the submit button: document.frames.iframeName.document.forms[0].submit(); Thanks for taking the time to respond. Turns out it wasn't pointless after all, eh? |
|
#4
|
||||
|
||||
|
sorry, I didn't mean to call it pointless... (sounds fairly rude, eh? sorry)
![]() Looks like you've found the DOM way to do it, which I was going to point out once I got a better grasp on what you're trying to accomplish. So the button on the main page has an onclick which submits the iFrame form? I still don't exactly follow... but it sounds like you've figured it out... and I guess that's what matters most =) This sounds like a good place to apply AJAX... I'd be careful with relying on Javascript though, of a user has it disabled your whole application is shot. |
|
#5
|
|||
|
|||
|
Hey Dzz, sounds like you've got the idea. The submit button in the main page actually does double duty: first it calls the user form into the iframe (because the iframe begins with a tabular report-type listing of database records), then, when the user data fields are filled in, the same button processes the user input into the db and reloads the initial tabular report file, now updated with the user's last input.
I elected to structure the file in that way (with the submit button in the main page, rather than on each of the 2 files which occupy the iframe at different times), because I wanted the submit button to always be visible to the user, rather than having to scroll down the inframe files to find individual, separate submit buttons on each of the content files. Thanks for the comment in re: AJAX. I'm aware of the JS limitations, but I'm totally unfamiliar with AJAX, and I'm not sure that I'm ready for a brand new learning curve just yet. |
|
#6
|
|||
|
|||
|
HEY if you want to submit parent form from iframe then use
window.parent.form[x].submit(); have fun ravs HEY Quote:
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > JavaScript Development > Can Parent Form Submit Button post IFrame Form Data? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|