Click to See Complete Forum and Search --> : Triggering page submit from another frame
geuis
02-03-2003, 06:06 PM
I have a window with 2 frames. In one frame, mainFrame, I have a regular button, not a submit/reset. In my second frame are going to be loaded pages that can only be completed by a submit. Each page has its own submit, but what I am trying to do is to get it so that each page, regardless of its content, will perform a submit operation when the button in mainFrame is clicked, kind of as a 'remote control' submit. The code I've included is what I've tried so far, but its so far gone I know it doesn't work. Any help on this is appreciated.
<html>
<!--Next and Back buttons page
<script language="javascript">
function nextBack()
{
location.submit
}
</script>
<body>
<!--<form name="form1" action="parent.document.forms[0].submit()" target="menuFrame">
<input type="button" value="Back">
<input type="button" value="Next" onclick="nextBack()">
<!--</form>
</body>
</html>
geuis
02-03-2003, 08:17 PM
When I try that, I get an error 'top.menuFrame.document' is null or not an object.
I've even tried changing the forms[0] to a specific name given to the form in question, ie <form name="form1"> and it gives the same error.
geuis
02-05-2003, 12:14 PM
Yeah, mainFrame is the name of the frame that the documents load into. Also yes, all of the pages that are being loaded into the frame that need to be submitted remotely are from our domain.
Geuis
geuis
02-06-2003, 11:39 PM
Its not created through document.write. The pages that are loaded are pre-made.
geuis
02-10-2003, 12:52 PM
This is the code from the first page that loads into the frame. For security reasons, I had to take out certain parts of the code, but nothing that will affect the operation of the submit function.
<html>
<head>
<title>DAT Tool</title>
<style>
<!--
div.Section1
{page:Section1;}
-->
</style>
</head>
<script language="JavaScript">
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}
//-->
</script>
<SCRIPT LANGUAGE=JAVASCRIPT>
function NextBox(ObjName,ObjNum)
{
// 1st example
if (ObjName == "AreaCode")
{
// move to next text field
if (ObjNum == 3) {
document.FrontPage_Form1.AreaCode.focus()
if (document.FrontPage_Form1.AreaCode.value.length == "3")
{
document.FrontPage_Form1.PhoneNumber.focus()
}
else
{
document.FrontPage_Form1.AreaCode.focus()
}
}
}
}
// End -->
</SCRIPT>
<body bgproperties="fixed" bgcolor="FFFFFF" onload="document.FrontPage_Form1.AreaCode.focus()">
<!--webbot BOT="GeneratedScript" PREVIEW=" " startspan -->
<script Language="JavaScript" Type="text/javascript"><!--
function FrontPage_Form1_Validator(theForm)
{
if (theForm.AreaCode.value == "")
{
alert("Please enter a value for the \"Area Code\" field.");
theForm.AreaCode.focus();
return (false);
}
if (theForm.AreaCode.value.length < 3)
{
alert("Please enter at least 3 characters in the \"Area Code\" field.");
theForm.AreaCode.focus();
return (false);
}
if (theForm.AreaCode.value.length > 3)
{
alert("Please enter at most 3 characters in the \"Area Code\" field.");
theForm.AreaCode.focus();
return (false);
}
var checkOK = "0123456789";
var checkStr = theForm.AreaCode.value;
var allValid = true;
var validGroups = true;
for (i = 0; i < checkStr.length; i++)
{
ch = checkStr.charAt(i);
for (j = 0; j < checkOK.length; j++)
if (ch == checkOK.charAt(j))
break;
if (j == checkOK.length)
{
allValid = false;
break;
}
}
if (!allValid)
{
alert("Please enter only \"0123456789\" characters in the \"Area Code\" field.");
theForm.AreaCode.focus();
return (false);
}
if (theForm.PhoneNumber.value == "")
{
alert("Please enter a value for the \"PhoneNumber\" field.");
theForm.PhoneNumber.focus();
return (false);
}
if (theForm.PhoneNumber.value.length < 7)
{
alert("Please enter at least 7 characters in the \"PhoneNumber\" field.");
theForm.PhoneNumber.focus();
return (false);
}
if (theForm.PhoneNumber.value.length > 7)
{
alert("Please enter at most 7 characters in the \"PhoneNumber\" field.");
theForm.PhoneNumber.focus();
return (false);
}
var checkOK = "1234567890";
var checkStr = theForm.PhoneNumber.value;
var allValid = true;
var validGroups = true;
for (i = 0; i < checkStr.length; i++)
{
ch = checkStr.charAt(i);
for (j = 0; j < checkOK.length; j++)
if (ch == checkOK.charAt(j))
break;
if (j == checkOK.length)
{
allValid = false;
break;
}
}
if (!allValid)
{
alert("Please enter only \"1234567890\" characters in the \"PhoneNumber\" field.");
theForm.PhoneNumber.focus();
return (false);
}
if (theForm.FIRSTNAME.value == "")
{
alert("Please enter a value for the \"FIRSTNAME\" field.");
theForm.FIRSTNAME.focus();
return (false);
}
if (theForm.LASTNAME.value == "")
{
alert("Please enter a value for the \"LASTNAME\" field.");
theForm.LASTNAME.focus();
return (false);
}
if (theForm.EMAIL.value == "")
{
alert("Please enter a value for the \"EMAIL\" field.");
theForm.EMAIL.focus();
return (false);
}
if (theForm.Problem.selectedIndex < 0)
{
alert("Please select one of the \"Problem Code\" options.");
theForm.Problem.focus();
return (false);
}
if (theForm.Problem.selectedIndex == 0)
{
alert("The first \"Problem Code\" option is not a valid selection. Please choose one of the other options.");
theForm.Problem.focus();
return (false);
}
if (theForm.OSType.selectedIndex < 0)
{
alert("Please select one of the \"OS Type\" options.");
theForm.OSType.focus();
return (false);
}
if (theForm.OSType.selectedIndex == 0)
{
alert("The first \"OS Type\" option is not a valid selection. Please choose one of the other options.");
theForm.OSType.focus();
return (false);
}
if (theForm.tech_type.selectedIndex < 0)
{
alert("Please select one of the \"Tech Type\" options.");
theForm.tech_type.focus();
return (false);
}
if (theForm.tech_type.selectedIndex == 0)
{
alert("The first \"Tech Type\" option is not a valid selection. Please choose one of the other options.");
theForm.tech_type.focus();
return (false);
}
if (theForm.CPE.selectedIndex < 0)
{
alert("Please select one of the \"CPE\" options.");
theForm.CPE.focus();
return (false);
}
if (theForm.CPE.selectedIndex == 0)
{
alert("The first \"CPE\" option is not a valid selection. Please choose one of the other options.");
theForm.CPE.focus();
return (false);
}
if (theForm.PrevNotes.selectedIndex < 0)
{
alert("Please select one of the \"Checked Previous Notes\" options.");
theForm.PrevNotes.focus();
return (false);
}
if (theForm.PrevNotes.selectedIndex == 0)
{
alert("The first \"Checked Previous Notes\" option is not a valid selection. Please choose one of the other options.");
theForm.PrevNotes.focus();
return (false);
}
return (true);
}
//--></script>
<!--webbot BOT="GeneratedScript" endspan -->
<form method="POST" name="FrontPage_Form1" action="default2.cfm" onsubmit="return FrontPage_Form1_Validator(this)" language="JavaScript">
<p align="left">
<i>
<font size="6" face="Challenge Extra Bold LET" color="#00FF00">Internal Tool</font>
</i>
</p>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1" bgcolor="#6699FF">
<tr>
<td width="100%" bgcolor="#6699FF"></b>
<br>
<!--webbot bot="Validation" s-display-name="Area Code" s-data-type="String" s-allow-other-chars="0123456789" b-value-required="TRUE" i-minimum-length="3" i-maximum-length="3" -->
<input name="AreaCode" size="3" maxlength="3" onChange="rough(this.form);" onkeyup="NextBox('AreaCode',3);" tabindex="1">-<font size="4">
<!--webbot bot="Validation" s-display-name="PhoneNumber" s-data-type="String" s-allow-other-chars="1234567890" b-value-required="TRUE" i-minimum-length="7" i-maximum-length="7" -->
<input name="PhoneNumber" size="8" value="" maxlength="7" tabindex="2">
<a class="link" href="javascript:form.reset();"></a>
</b>
</font>
</td>
</tr>
<tr>
<td width="100%">
<!--webbot bot="Validation" b-value-required="TRUE" -->
<input type="text" name="FIRSTNAME" id="required2" size="20" tabindex="3">
<!--webbot bot="Validation" b-value-required="TRUE" -->
<input type="text" name="LASTNAME" id="required3" size="20" tabindex="4"> Thank You !!!
<br>
<font face="Times New Roman" color="black" size="3">
<span style="FONT-SIZE: 12pt; COLOR: black">
</span>
</font>
<br>
<font size="4">
<!--webbot bot="Validation" b-value-required="TRUE" -->
<input type="text" name="EMAIL" id="required4" size="13" tabindex="5">
</font>
Thank You !!!<br>
How may I help you ?<br>
<textarea rows="3" name="TSSteps" cols="49" tabindex="6">
</textarea>
</td>
</tr>
<tr>
<td width="100%"> </td>
</tr>
<tr>
<td width="100%">
<font >
<!--webbot bot="Validation" s-display-name="Problem Code" b-value-required="TRUE" b-disallow-first-item="TRUE" -->
<select size="1" name="Problem" tabindex="7">
<option value="Null">- Problem Type -</option>
</select>
<!--webbot bot="Validation" s-display-name="OS Type" b-value-required="TRUE" b-disallow-first-item="TRUE" -->
<select size="1" name="OSType" tabindex="8">
<option>OS Type</option>
<option>N/A</option>
</select>
<!--webbot bot="Validation" s-display-name="Tech Type" b-value-required="TRUE" b-disallow-first-item="TRUE" -->
<select size="1" name="tech_type" tabindex="9">
<option selected>Tech Type</option>
</select>
<!--webbot bot="Validation" s-display-name="Checked Previous Notes" b-value-required="TRUE" b-disallow-first-item="TRUE" -->
<select size="1" name="PrevNotes" tabindex="11">
<option selected>Checked Notes?</option>
<option value="Yes">Yes</option>
<option value="No">No</option>
<optionvalue="No">
</select> </font>
<optionvalue="No">
<optionvalue="No">
<optionvalue="No">
<font>
<input type="submit" value="Next >>" name="Next1" tabindex="12">
</font>
<input type="reset" value="Reset" name="B3" tabindex="12">
</tr>
</table>
<p align="center"><br>
</p>
</form>
</body>
</html>
geuis
02-10-2003, 07:18 PM
Heh. This wasn't a page I could link to from the outside. Looking at it, do you see a problem that would prevent a remote submit from another frame?
geuis
02-10-2003, 08:04 PM
<html>
<head>
<title>Remote Load</title>
</head>
<frameset rows="500,30,300" border="2">
<frame src="menuFrame.html" noresize marginheight="0" marginwidth="0" scrolling="no" name="menuframe">
<frame src="centerform.html" noresize marginheight="0" marginwidth="0" scrolling="auto" name="contentframe">
<frame src="inContentFrame.html" name="content2">
</frameset>
</html>
geuis
02-12-2003, 10:38 AM
er. update
geuis
02-16-2003, 04:45 PM
Maybe this is the reason I was getting the error. The window is divided into 3 frames. The top frame where the submit() is being done is named menuFrame, the middle frame is where the Next button that triggers the submit is, and the bottom frame simply loads an information page automatically and is not really related to the problem.
The code to reference the menuFrame frame is "top.menuFrame.document..."
Is it possible that "top.menuFrame" is making the browser think that the frame is inside the contentFrame frame?
geuis
02-16-2003, 05:58 PM
I finally got a different response with this code.
<body>
<input type="button" name="Next" onClick="top.menuframe.FrontPage_Form1.submit()">
</body>
</html>
I now get the error "Permission Denied."
At least its progress. Don't really understand what could be prevent it access, unless its a coding violation.
Geuis
geuis
02-16-2003, 07:26 PM
hmm... its an internal company domain. Could it be giving this problem because the page its being triggered from is stored locally on my machine, thus technically a different domain? And if so, is there any workaround?