Solved

Submit form from different frame

Posted on 2003-11-17
7
1,474 Views
Last Modified: 2012-06-27
Each method I have used so far seems to ignore the onsubmit event handler on the form in frame1.

Any ideas?

frame1.htm:
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form name="form1" method="post" onsubmit="return verify(this);"

action="../screens/xmlCreate.jsp">
<textarea name="field1" cols="50" rows="4"></textarea>
</form>
</body>
</html>

frame2.htm

<html>
<head>
<title>Untitled Document</title>
</head>
<body>
  <a href="javascript:parent.mf_mainFrame.form1.submit();">Submit</a>
</body>
</html>
0
Comment
Question by:kate99
  • 4
  • 2
7 Comments
 
LVL 16

Expert Comment

by:jaysolomon
ID: 9764935
<a href="#" onclick="parent.mf_mainFrame.document.form1.submit();return false;">Submit</a>

or

<a href="#" onclick="parent.frames['frameName'].document.forms['form1'].submit();return false;">Submit</a>

0
 
LVL 10

Expert Comment

by:NetGroove
ID: 9765168
Like this:

<a href="#" onClick="if(parent.mf_mainFrame.verify(parent.mf_mainFrame.form1) parent.mf_mainFrame.form1.submit;return false">Submit</a>



0
 
LVL 10

Expert Comment

by:NetGroove
ID: 9765175
Sorry, take this:

<a href="#" onClick="if(parent.mf_mainFrame.verify(parent.mf_mainFrame.form1) parent.mf_mainFrame.form1.submit();return false">Submit</a>


0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:kate99
ID: 9769696
Thanks for your reply's.

In the end this worked:

<a href="#" onClick="if(parent.mf_mainFrame.verify(parent.mf_mainFrame.form1))parent.mf_mainFrame.form1.submit();">Submit</a>

What shall i do with the points? Netgroove's answer was nearest. Anyway let me know.

Cheers
0
 
LVL 10

Accepted Solution

by:
NetGroove earned 50 total points
ID: 9769947
What does mean nearest?
If you do not add ";return false"  that it is false but error tollerant.
Clicking on a <a> link will load the window with the link in the href.
The return value kills that default window load behaviour.

The naswer from jaysolomon  circumvents the validate()  function and submits only the form.

So does my proposal solve your problem.

By the way, there are more elegant ways doing what you want to do, but I prefered not to confuse you with details and keep the things like they are actually.



0
 
LVL 16

Expert Comment

by:jaysolomon
ID: 9771026
You should return false so that the link will not be followed.

>>nearest?

If your not satisfied, then tell us whats not right for you and we will try to suit your needs.

You have 2 options with the points

1 accept the answer that fullfills your requirements.

2 split the points between the experts that helped you.

Good Luck

jAy
0
 
LVL 10

Expert Comment

by:NetGroove
ID: 9782468
Thanks for the points.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
When you need to keep track of a simple list of numbers or strings, the Array object is your most direct tool.  As we saw in my earlier EE Article (http://www.experts-exchange.com/A_3488.html), typical array handling might look like this: (CODE) B…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now