Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Submit FORM from function called by another form 1

Status
Not open for further replies.

ddchaos

Programmer
Nov 13, 2000
6
US
This function is called from one of two forms on a page. It checks to see if the data in the other form has been changed. If so, and if the user has not clicked on the update button, it asks the user whether or not to update the data. Everything works fine until I try to submit the other form. Then I get a message saying "Object does not support this property or method."

frm is the form that calls the function, url is the next page.


function submitThis(frm, url){
if(document.forms.data.changed.value == "changed"){
var msg = "You have changed the data in this form ";
msg += "but have not clicked the update button.";
msg += "\nIf you want to change it, click OK.";
msg += "\nOtherwise click cancel.";
var response = confirm(msg);
if(response){
document.forms.data.submit(); <== Always fails here
}else {
// User doesn't want to save change
frm.action = url;
frm.submit();
}
}
// Document is unchanged
frm.action = url;
frm.submit();
}

The other two instances of the frmName.submit() in this function work with no problem.

Any help will be greatly appreciated.

Paul
 
in the red you have forms.data --- what is .data? jared@aauser.com
 
data is the name of the form I'm trying to submit. I've seen a bunch of ways to refer to the form you want to submit including:

frmname.submit()
document.forms.frmname.submit()
document.forms[form_index].submit()
document.forms.frmname.submit(frmname)

I've tried 'em all but none seem to work in this context.

Thnks
 
Can you post a link to the page so I can see it in its entirety? jared@aauser.com
 
Hi ddchaos,

if &quot;data&quot; is the name of your form,
you can do &quot;document.data.submit()&quot; to submit it
it is better we see more your code or put up the link so we can take a look at it

hope this helps



Chiu Chan
cchan@gefmus.com
 
Here's the link. This is only functional up to the second level (previous.asp). You'll have to fill out candidate.asp completely in order to get there, making sure to choose &quot;Yes&quot; for &quot;Have you applied for a job OR worked at Venoco in the past?&quot; Then fill out at least one previous position and click &quot;Add Another&quot; so the &quot;Show me what I've got so far.&quot; link will show up. When you click on &quot;Show me what I've got so far.&quot; a pop-up opens. Click on &quot;Change&quot; to get back to previous.asp. Make a change in the form and then click on the &quot;Candidate Info&quot; link before updating. This will open a new pop-up advising you that you have changed the data but not updated it. Clicking the &quot;Update&quot; link should submit the form named &quot;data&quot; in previous.asp... but it doesn't. And that's what's killin' me.

Thanks a million

Paul

 
jaredn and PepperPepsi...

FYI in case you get a chance to look at the code...

1) I have changed the name of the form in previous.asp to frmData
2) I am now calling the code from a pop-up rather than using the confirm message box.

Thanx
 
Hi ddchaos,

Here is the problem
in form frmData you have the following..

<INPUT TYPE=&quot;submit&quot; VALUE=&quot;Update&quot; NAME=&quot;submit&quot;>

notice that the name of this submit button is &quot;submit&quot;!

so when you do &quot;opener.document.frmData.submit();&quot; in your pop up window, javascript will read the frmData.submit not frmData.submit(), to fix this problem, simply rename your submit button to

<INPUT TYPE=&quot;submit&quot; VALUE=&quot;Update&quot; NAME=&quot; submit&quot;> (with the space in front) or a compelete different name like
<INPUT TYPE=&quot;submit&quot; VALUE=&quot;Update&quot; NAME=&quot; submitnow&quot;>

I tried it on my PC and it works, if you have problem please let me know =)

hope this helps




Chiu Chan
cchan@gefmus.com
 
That was exactly the problem! As soon as I changed the name it all worked. Thank you PepperPepsi and to all who helped.

Paul
 
This thread has also solved the very same problem that I was having! Thanx to you all and Happy Xmas.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top