Solved

Manipulating a jsp form via a different form

Posted on 2003-11-25
5
295 Views
Last Modified: 2010-04-01
Hi,
I have a Main.jsp that includes an iframe tag.
The iframe includes a frame.jsp file.

Main.jsp :

<iframe name = "jspFrame" height="150" width="800" marginheight="10" marginwidth="10"  frameborder="1"   scrolling="auto" > > </iframe>

<script>
setFrame();
function setFrame(){
var taskConfigFrame = document.getElementById('jspFrame');
            taskConfigFrame.setAttribute('src', 'frame.jsp');
}
</script>

How can I call a javascript function in frame.jsp or perform a submit to the frame.jsp if all I have is a submit button of the Main.jsp?
All actions I want to do via the Main.jsp, I don't want to create a submit button in frame.jsp.
Please advise
Thanks
Jo

0
Comment
Question by:YossiBa
  • 3
  • 2
5 Comments
 
LVL 14

Expert Comment

by:kennethxu
ID: 9822115
you can use submit button to submit the form in frame or form in main. but not both.
to submit the form in iframe:

NS 6.2 +

  window.frames['ifMyIFrame'].document.frmSubmit.submit();

IE 5.0 +

  document.ifMyIFrame.frmSubmit.submit();
0
 

Author Comment

by:YossiBa
ID: 9822841
Hi,
After using the following in Main.jsp:

taskConfigFrame = document.getElementById('jspFrame');
            taskConfigFrame.setAttribute('src', 'frame.jsp');

I used:
  taskConfigFrame.document.forms[0].submit();

and it does the work, it submit the iframe (frame.jsp) but...

the submit in the frame.jsp is a s follows:
<input type="submit" onclick="setSaveWasClicked('true');"/>
and i need to use the function setSaveWasClicked() when submitting the form but when I submit from Main.jsp it only do a submit without going through the function.

How can I do a submit with using onclick function?
Thanks
0
 

Author Comment

by:YossiBa
ID: 9823200
Hi kennethxu,
remove the last mail that I sent from the protocol.
What I wrote does not submit the iframe.I couldn't understand  document.ifMyIFrame.frmSubmit.submit();

I want after pressing the submit button in Main form I have a function that should submit the frame.
If the frame id is "frameForm", how the submit command should be?
please advise
thanks
0
 
LVL 14

Expert Comment

by:kennethxu
ID: 9826240
>> the submit in the frame.jsp is a s follows:
>> <input type="submit" onclick="setSaveWasClicked('true');"/>
then, you should actually be calling the function instead of simpley submitting the form:
taskConfigFrame.setSaveWasClicked('true');
0
 
LVL 14

Accepted Solution

by:
kennethxu earned 100 total points
ID: 9826256
sorry you'll still need to submit it after function call:
taskConfigFrame.setSaveWasClicked('true');
taskConfigFrame.frameForm.submit();
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial shows how to create a greeting card by combining two image layers and a text layer on a PC using a free image editing app.
Adding Computers to AD groups through an SCCM Task Sequence
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.

825 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