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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ifrmae form

Status
Not open for further replies.

lonelydragon

Programmer
Aug 5, 2004
75
0
0
US
hello,
i am tring to submit a iframe form from JS in the parent. but it works in IE, and not in fireforx. anyoen can help?
the code i use isone of the following:
window.frames['groupFile'].document.groupForm.submit();
//window.frames['groupFile'].document.getElementById('groupForm').submit();
 
Try:

Code:
window.frames['groupFile'].document.forms['groupForm'].submit();

If that fails, make sure the form named "groupForm" has no element named "submit".

Hope this helps,
Dan

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Does your iframe have a name attribute of groupFile, and a form within that with a name of groupForm?

Make sure the case is correct (so lowercase "g" and upeprcase "F" in both cases in your name attribute).

Dan

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
yes, the iframe has name and id "groupFile" ; and the form within the iframe have the name and id "groupForm
 
tried the following without any luck:
top.frames['groupFile'].document.groupForm.submit();
//window.frames['groupFile'].document.groupForm.submit();
// window.frames['groupFile'].document.getElementById('groupForm').submit();
//window.frames['groupFile'].document.forms['groupForm'].submit();
//document.getElementById('groupFile').contentWindow.document.groupForm.submit();
 
in the iframe, the code is:
<form name=groupForm id=groupForm method=POST>
<input type=hidden name=cPntr id=cPntr >
<input type=hidden name=groupName id=groupName value=''>
<input type=hidden id=selectedNum name=selectedNum value=''>
<input type=hidden name=updateGroup id=updateGroup value=''>
<input type=submit value=submit>
<div id=groupDivA></div>
<div id=groupDivB></div>
</form>

in the parent:
i have some radio options and a iframe, and on click the radio, call the javascript function in the parent, and javascript function then pass some data to the hidden fields in the iframe, and then submit the form
 
the code in the parent:
<table>
<tr><td><input type=radio id=addC name=add_opt value=group onclick=\"csvShow('group');\" > Use saved student group(s)</td></tr>

<tr><td>
<iframe name=groupFile id=groupFile src='csvfile.php' class='' allowtransparency=true framespacing=0 frameborder=no border=0 width=500px scrolling='no' height=150px></iframe>
</td></tr>
</table>

<script>
var numleft = document.getElementById('numLeft').value;
var selectedCR = document.getElementById('selectedCR').value;

window.frames['groupFile'].document.getElementById('cPntr').value = selectedCR;

window.frames['groupFile'].document.getElementById('groupForm').submit();
</script>
 
Change this:

Code:
<script>

to this:

Code:
<script [!]type="text/javascript"[/!]>

You should [!]always[/!] specify the type of script, otherwise some browsers will ignore it, as they would have to guess at the language you are using.

Dan

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Anyway - you are running the script inline - so you could well be trying to submit the form before it has even loaded. Try moving the code to a function which is called onload, etc.

Dan



[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
actually, i do have that in my code, when i typied them here, i did. thanks
 
and also , the JS code is not inline, it is External JavaScript
 
Enclose all your attributes with quotes!!! That is not acceptable to moz-ff. Mind to do that and retest.
 
How the hell do you expect us to help if the code you're showing us is not the code on your page? Really - come on... this should be common sense!

Now - how about you show us the REAL code you have before this thread simply gets red flagged and deleted?

Dan



[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
now i Enclose all attributes with quotes. but nothing happens, and alo ,i just found if i add aler("something") in the JS code before the submit(), it works, but if i remove the alert, nothing happen again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top