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

How do I have Frame A to validate Frame B's form?

Status
Not open for further replies.

OutInLeftField

Programmer
Apr 30, 2002
37
US
Hello,

This is a doozy.

I am trying to validate a form in Frame B from Frame A's submit button.

The frameset looks like:
<FRAMESET rows="85%, 15%">
<FRAME src="<%=session("passedValue")%>" name ="Page1"/>
<FRAME src="Submit.asp" name ="Submit"/>
</FRAMESET>

The sessionobject is whatever the previous page's input value of the pagename (see below explanation) passed.

because each page has session("passedValue") =request("NextPage"). When someone refreshes the page, I want the current page to reload. So on each page in the form element I have:
<input type ="hidden" name = "NextPage" value ="mypagename.asp"/>

this keeps the page from going to the next page if the user refreshes the page and reloads the current page name passed from the previous page.


The parent has:
...

function frame2()
{
parent.Page1.document.FormSubmit.submit();
}

function frame2Reset()
{
parent.Page1.document.FormSubmit.reset();
}
--> -->
</script>

(within the form element)
<input type="button" value = "Next Page" name ="Submit" onclick ="frame2()"/>
<input type ="button" Value = "Clear Form" name ="Reset" onclick ="frame2Reset()"/>

Now. on each page I have js scripts to check for errors. If a certain field is incorrect, I change the color of that value to red. I also increment a counter at that point. At the end of the page what I want to do is see if the count of the red values > 0 then stop submission. I cannot use onsubmit="myfunction()" on each page because the frame has the form.submit (see above).

So lies the problem. When I click on Submit in the lower frame, the function to validate the current page is never executed because the lower frame has the: parent.Page1.document.FormSubmit.submit();


1. Is there a way within in the submit function in the parent to check the count?
2. Is there a way to stop submission within the frame if the count > 0?

thank you very much
 
looks like what you might need is a function on each page (let's call it "doSubmit") to validate the form. if the form fully validates, call the submit event. if it doesn't, dont call the submit event.

change your function do this:

Code:
function frame2()
{
    parent.page1.doSubmit();
}


oh, and WHY FRAMES??



*cLFlaVA
----------------------------
[tt]mr. pibb + red vines = crazy delicious![/tt]

[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
Thank you for the quick reply!

The answer to the Frames question is because the this was a requirement from the users. Oh well...make the users happy eh?

Now the first part.

Now this will sound like a dumb ? How do I fully validate the form in order to fire the js to allow the parent frame to fire the submit? What event would work at the end of the page to say if the count > 0 then allow the submit command on parent frame to fire?

 
your button will call your frame2 function. that function will call the function named doSubmit, which resides on the page your form resides on.

i can't tell you much more. you said you had a function that counts errors, makes them red, etc. at the end of the function, you can test the counter value. if it's 0, submit the form. if it's not 0, display a message (if you want) and then DO NOT submit the form.

i can't tell you any more without seeing code or a link.



*cLFlaVA
----------------------------
[tt]mr. pibb + red vines = crazy delicious![/tt]

[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
Ok..Now I understand. I'll try it.

thank you so much for your assistance.
 
This is what I've done. no success yet.

Am I missing something or syntax incorrect?


The submit function went from
function frame2()
{
parent.Page1.document.FormSubmit.submit();
}

to
{
var a = parent.Page1.document.FormSubmit.doSubmit()
if (a)
parent.Page1.document.FormSubmit.submit();
else
alert("You have problems with the page. Please make corrections and click on 'Next Page' again.");
}

the function doSubmit() that is located on the page that checks the count:
function doSubmit()
{
if (count > 0)
return false;
else
return true;
}


The error I get is : "Object does support this property or method" on " var a = parent.Page1.document.FormSubmit.doSubmit()
 
a) just use [tt]parent.Page1.doSubmit()[/tt] if Page1 is the name of the frame.
b) why are you returning something? you could call the submit event in the doSubmit function itself, you know...



*cLFlaVA
----------------------------
[tt]mr. pibb + red vines = crazy delicious![/tt]

[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
I'm getting closer!

In the submit button, I have "parent.Page1.doSubmit();" as you suggested

All of the pages have no validation have the count set to 0 automatically to send it along:

function doSubmit()
{
count = 0;
if (count > 0)
alert("no way!");
else
parent.Page1.document.FormSubmit.submit();
}

and the page that does have the validation has the local variable taken out. The counter is :

function doSubmit()
{
if (count > 0)
alert("no way!");
else
parent.Page1.document.FormSubmit.submit();

The first two pages it worked but on the third page with the counter, I get the error "Object doesn't support this property or method" on line:
<input type="button" value = "Next Page" name ="Submit" onclick ="parent.Page1.doSubmit();"/>

now what??

thank you for your help?
}
 
I got it working.

thank you for all of your help!

I have to put this function on All pages in order for this to work.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top