Click to See Complete Forum and Search --> : Handling Multiple Forms
I asked this question earlier,but I seem to have lost the thread.
Anyway, here goes my question:
I have two tabs : tab1 and tab2
tab1 is wrapped in a form called frm1
tab2 is wrapped in a form called frm2
Upon clicking a tab, the page is loaded in an iframe.These pages are basically user entry forms.
The scenario is:
The user fills info in tab1.He clicks tab2.Upon clicking tab2, two things should happen: It should submit frm1 with all the values entered and also load page for tab2 in the iframe.
I would really appreciate if someone can help me give an example of how to do this.
Many Thanks
Here is my url:
http://mili.home.att.net/html/main.html
Can some one please help me with this?
Thanks
AdamBrill
07-24-2003, 08:57 AM
Try a little patience... ;)
Anyway, you should be able to do that with a simple JavaScript. When they click the link for the second tab, run a function like this:function body_link(){
if(document.header){
document.header.submit();
}
document.location="wherever.htm";
}
Something like that should work. Let me know if you have any problems with it. :)
Thanks Adam..
But my problem is that the user could navigate to any tab at any point of time.How do I know where he is leaving,so that I can submit that form?
I have a problem.This function doesnt seem to submit the header tab.
function bodyLink(){
if(document.editHeader){
alert("Submitting Header");
var tab1 = document.editHeader.tab1.value;
alert(tab1);
document.editHeader.submit();
}
alert("Calling Body");
}
I dont know why.Pls help me!
AdamBrill
07-24-2003, 08:07 PM
Well, from what I saw on your page, editHeader isn't your form name. If it isn't, then that would be the problem. If it is, then it should be working. Do all of the popups work?
I have no problems loading the pages to the iframe.
I want to be able to submit the previous form that I just left.
about the naming conventions, sorry...I changed them.
Anyway, I got it to work if I navigate from header to body.But I need a more generic function
function bodyLink(){
var tab1=document.forms[0].tab1.value;
alert(tab1);
document.forms[0].submit;
alert("Calling Body");
}
AdamBrill
07-25-2003, 08:30 AM
That 'generic function' should work fine. ;) Is it still not working to submit it like that? That is really weird.. Here are a few things to try:
1. Put the () after the submit. So it would look like this:
document.forms[0].submit();
2. Make sure you don't have a form element named 'submit'
If it still isn't working, could you attach your entire page for me to look at?
Adam,
Thanks.
I got it to work finally.The reason I said it was not generic is because I was using forms[0].I should not be hadcoding the index.So I declared a variable for indexing the form.
Thanks for you help, Adam.
:)