This is a discussion on How can I get the elements index number of a form field using 'this'? within the HTML, CSS and Javascript Coding Techniques forums, part of the Web Development category; Hi all.... How can I get the elements index number of a form field using 'this'? Thanks & Regards P....
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
|
#1
| |||
| |||
| Hi all.... How can I get the elements index number of a form field using 'this'? Thanks & Regards P.vinothkumar |
|
#2
| |||
| |||
| Hi... <script language="JavaScript"><!-- function getIndex(what) { for (var i=0;i<document.myForm.elements.length;i++) if (what == document.myForm.elements[i]) return i; return -1; } function test(what) { alert(getIndex(what)); } //--></script> <form name="myForm"> <Input type="button" value="Button0" onClick="test(this)"> <input type="button" value="Button1" onClick="test(this)"> <input type="button" value="Button2" onClick="test(this)"> <input type="button" value="Button3" onClick="test(this)"> </form> Thanks.... |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Number sign in Textarea Field causing php problems | karisegraves | PHP Programming | 1 | 01-04-2009 04:20 AM |
| Date/time stamp a form field as the form is submitted | itbarota | HTML, CSS and Javascript Coding Techniques | 1 | 02-06-2008 09:16 PM |
| Date/Time stamp a form field as the form is submitted | itbarota | HTML, CSS and Javascript Coding Techniques | 2 | 01-17-2008 07:47 PM |
| How can I clear the form field values after the user has submitted the form for clien | itbarota | HTML, CSS and Javascript Coding Techniques | 1 | 11-01-2007 10:39 PM |
| Form elements | tripnautic | HTML, CSS and Javascript Coding Techniques | 1 | 03-20-2007 06:40 AM |
Our Partners |