By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,946 Members | 1,701 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,946 IT Pros & Developers. It's quick & easy.

Javascript form number

P: n/a
rd
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
Jul 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"rd" <be**********@myway.com> wrote in message
news:8d**************************@posting.google.c om...
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?


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;
}
Jul 20 '05 #2

P: n/a
rd
Thanks!

"Vjekoslav Begovic" <vj*******@inet.hr> wrote in message news:<bp**********@ls219.htnet.hr>...
"rd" <be**********@myway.com> wrote in message
news:8d**************************@posting.google.c om...
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?


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;
}

Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.