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

how to see if submit but was pressed

Status
Not open for further replies.

mcghee31

IS-IT--Management
Dec 13, 2007
12
0
0
US
I am trying to test to see if a submit button was pressed on a form using

Code:
<script>
if(document.req.submit){
  alert('testing');
}
</script>

the form code start with <form method="post" action="">

the submit button code is <input type="submit" id="submit" value="submit"

What am I missing are doing wrong?

I tried document.req.onsubmit but no luck either

thanks


 
thanks Glen, I am trying to build an external script and thus that example is one way to validate but I was look to validate it in the external script

I changed my tack to: <form onSubmit="passVals()" >

In the head of the html doc I have

<script>

function passVals() {
alert('testing');
}

That method worked like a charm but know I have another questions with the same doc. This is an HTML doc that's called from a parent HTML doc; is there a way to get the name of the parent html doc that called this window?

Thanks for the input
 
I tried code on the child form

Code:
function passVals() {

   document.appts.req_f_name.value ='testing';

}

//appts is the name of the parent form
//req.f_name is the name of a text box on the parent form

Any ideas what I am missing?
 
Ok I got it I had to add .document

window.opener.document.appts.req_f_name.value ='testing';
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top