Connecting Tech Pros Worldwide Forums | Help | Site Map

Javascript form number

rd
Guest
 
Posts: n/a
#1: Jul 20 '05
How can I get the form number by using the this command?

document.forms[6] is the seventh form on the page

If the seventh form looked like this:

<form>
<input type="button" onclick="myFunction(this)">
</form>

How can I make myFunction return the number 6?

this.form.??


Thanks,

rd

Vjekoslav Begovic
Guest
 
Posts: n/a
#2: Jul 20 '05

re: Javascript form number


"rd" <bewareoffifi@myway.com> wrote in message
news:8de4eab3.0311182256.6ab6d9e8@posting.google.c om...[color=blue]
> How can I get the form number by using the this command?
>
> document.forms[6] is the seventh form on the page
>
> If the seventh form looked like this:
>
> <form>
> <input type="button" onclick="myFunction(this)">
> </form>
>
> How can I make myFunction return the number 6?[/color]

onclick="return myFunction(this.form)";

function myFunction(form){
var frms=document.forms;
for (var i=0; i<frms.length;i++){
if (frms[i] == form){
return i;
}
}
return null;
}


rd
Guest
 
Posts: n/a
#3: Jul 20 '05

re: Javascript form number


Thanks!

"Vjekoslav Begovic" <vjbegovic@inet.hr> wrote in message news:<bpfakj$ap3$1@ls219.htnet.hr>...[color=blue]
> "rd" <bewareoffifi@myway.com> wrote in message
> news:8de4eab3.0311182256.6ab6d9e8@posting.google.c om...[color=green]
> > How can I get the form number by using the this command?
> >
> > document.forms[6] is the seventh form on the page
> >
> > If the seventh form looked like this:
> >
> > <form>
> > <input type="button" onclick="myFunction(this)">
> > </form>
> >
> > How can I make myFunction return the number 6?[/color]
>
> onclick="return myFunction(this.form)";
>
> function myFunction(form){
> var frms=document.forms;
> for (var i=0; i<frms.length;i++){
> if (frms[i] == form){
> return i;
> }
> }
> return null;
> }[/color]
Closed Thread