Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-20-2002, 05:49 PM   PM User | #1
RobRichard
New to the CF scene

 
Join Date: Jun 2002
Location: PA, USA
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
RobRichard is an unknown quantity at this point
Question Hey javascript gods - iframe and onsubmit issue

I have a strange issue that someone may be able to help with...

I have an iframe on a page, and inside the iframe is another page with a form and some text fields and the like. I have a toolbar on the main page with a "SAVE" button on it, and the onclick of the button calls the iframe's form's submit method. I want to place some javascript in the onsubmit of the page with the form, but it ignores the onsubmit event. Everything is setup as you would do it if the page were by itself (ie, in the form tag I have onsubmit="javascript:doVerify();") but "doVerify" never executes. Any ideas Javascript gods?
RobRichard is offline   Reply With Quote
Old 06-20-2002, 06:23 PM   PM User | #2
JohnKrutsch
Regular Coder

 
Join Date: Jun 2002
Location: The Planet Earth Code Poet: True
Posts: 282
Thanks: 0
Thanked 1 Time in 1 Post
JohnKrutsch is an unknown quantity at this point
Post the code for you form and the doVerify function. Typically the onsubmit call would look like this:

onsubmit="return doVerify()"


I can't think of a time when you wouldever have to put:

javascript:

into a javascript event handler.
JohnKrutsch is offline   Reply With Quote
Old 06-21-2002, 04:11 AM   PM User | #3
RobRichard
New to the CF scene

 
Join Date: Jun 2002
Location: PA, USA
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
RobRichard is an unknown quantity at this point
Unhappy

hmmmm, perhaps I didn't layout the scenario well enough. Let's try this sample...

Create two HTML pages, call one page1.htm, the other call page2.htm. Put the code for each page accordingly...

page1.htm:

<html>
<head>
<script>
function doSaveClick() {
window.maintframe.document.forms(0).submit();
}
</script>
</head>
<body>
<center>
<input type=button id="save" name="save" value="save" onclick="javascript:doSaveClick();">
<p>
<iframe height="300" width="300" id="maintframe" name="maintframe" border="1" frameborder=1 scrolling="auto" src="page2.htm"></iframe>
</center>
</body>
</html>



page2.htm:

<html>
<head>
<script>
function doVerify() {
alert('Doing the verify function!');
}
</script>
</head>
<body>
<form id=maint name=maint onsubmit="return doVerify()">
Enter something: <input type=text id=txtText name=txtText>
<p>
Enter something else: <input type=text id=Text2 name=txtText2>
</form>
</body>
</html>


Then pull up page1.htm, and click the "Save" button. The form in the iframe submits, but the function doVerify is never executed. Is there a way to make that function fire? Or, is there a way to call doVerify from the button click?

Thanks for your help...
RobRichard is offline   Reply With Quote
Old 06-21-2002, 04:54 AM   PM User | #4
RobRichard
New to the CF scene

 
Join Date: Jun 2002
Location: PA, USA
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
RobRichard is an unknown quantity at this point
OH OH OH OH OH! Great idea... I tried a couple of variations and here is what works:

In the doSaveClick function:

function doSaveClick() {
window.maintframe.document.forms(0).submit();
window.maintframe.doVerify();
}

Works like a champ!
RobRichard is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:41 PM.


Advertisement
Log in to turn off these ads.