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 derfloh 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 another page and envoke the onSubmit command.

Status
Not open for further replies.

static786

Programmer
Feb 13, 2006
23
GB
It does'nt work, if i submit a form from another frame, it submits the form but does'nt envoke the onSubmit call on that page (I want it to call a javascript function on that page when it submits). anyone know of a workaround?

thanks.
 
The onsubmit event handler is part of the frame that's being submitted, not a page. You can call functions in a parent frame or page using parent.functionname() (if the function is in the parent) in the onsubmit event for the frame.

If you were to show your relevant code (not the whole pages of HTML and script), it would help immensely in answering your question.

Lee
 
onsubmit events do not get fired when calling a form's submit method programatically. This is normal.

Thus, if you are calling the submit method to submit the form, expect it never to be called. Instead, you will have to call "the function" (i.e. whatever is in the onsubmit handler) directly.

Hope this helps,
Dan

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
thanks for the replies, I' tried to set it as u suggested, but it does'nt seem to work:

window.opener.document.navigateForm.bbox.value = document.formTemp.bbox.value;

window.opener.document.mapLoad();


the first line where I set the input box works fine, the second line returns and error "Object does not support this propery or method".
 
window.opener is for communicating between popup windows and the ones that open them.

Lee
 
I know, thats why I'm using it. The page I;m sending the message from is a page opened by the page I want to send the message to.
 
You mentioned frames in your original post, though. Maybe you should show the relevant code (not the whole pages) so we can see what you're referring to.

Lee
 
the form from the window from which I want to pass the vakue from:

<form name="formTemp">
<input name="bbox" type="text" value="<cfoutput>#bbox#</cfoutput>">
<script language="JavaScript">

window.opener.document.navigateForm.bbox.value = document.formTemp.bbox.value;

window.opener.document.mapLoad();

</script>
</form>

therefore the script is exected once the value of the input box has been. The first statement successfully assigns the value of the text box in the target form/page. On tarhet oage there also exists a method mapLoad() which is defined in the header of the page.
 
also,

if(parent.map.document.mapForm.mode.value == null)
{
var newMode = "ZoomOut"
}
else
{
...
}

returns me an error saying that parent.map.document.mapForm.mode.value is null or not an object, if that was the case then by the above code should it not follow on to set the value of newMode rather than denerate an error?
 
If you're using frames, you should use

parent.map.document.mapForm.mode.value

If you're using a popup window, you need to use

window.opener

instead.

Lee
 
for this one here I;m using frames:


if(parent.map.document.mapForm.mode.value == null)
{
var newMode = "ZoomOut"
}
else
{
...
}

the other one, I'm using a pop up page.
 
Let's take things one a at a time, then, rather than mixing and matching and confusing those who are trying to help you.

The value will never be null if the element exists. You should probably check

if(parent.map.document.mapForm.mode.value.length == 0)

instead.

This says that the parent to the frame with this function has a frame called map that has a form called mapForm spelled EXACTLY like that, and that form has an element named mode spelled EXACTLY like that. The error message says that doesn't exist.

Since you're reluctant to show the relevant code, that's about all I can tell you to help you.

Lee


 
the error does'nt always come up, sometimes the frame I'm trying to access the value mode from fails to load before the test, other times it works fine.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top