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

Parent cell of a textbox 2

Status
Not open for further replies.

JLizOB

Programmer
Dec 5, 2007
45
CA
I am trying to return the index of a cell in a table, when a textbox is manipulated. I have an onchange event with the textbox and I am sending the textbox object as a parameter with the key word this. In my Javascript I am trying to obtain the index of the cell and row that the Textbox was contained in. I thought the following would work but had no luck, it returns undefined, and haven't found much in my searches.
Code:
function cell_onchange(sender)
{
    test = sender.cellindex;
    alert(test);
}

Any help would be appreciated. Thanks!
 
[tt]cell[red]I[/red]ndex[/tt]

- Lowet

[gray]Why can't all browsers parse pages the same way? It should be the Web designer who decides how to display the content, not the browser![/gray]
 
still no luck
here is my textbox in the table
Code:
<td>
<input [red]onchange="cell_onchange(this)"[/red] onfocus="cell_onfocus(this)" onblur="cell_onblur(this)" type="text" value="14" />
</td>
here is my javascript function
Code:
function cell_onchange(sender)
{
    alert(sender.cellIndex);
}
 
You're sending the function an Input element, not a cell element.

alert(sender.parentNode.cellIndex);

Never be afraid to share your dreams with the world.
There's nothing the world loves more than the taste of really sweet dreams.

Webflo
 
It's ok Lee... when I'm gone I want you to have all my stars anyway :)

Never be afraid to share your dreams with the world.
There's nothing the world loves more than the taste of really sweet dreams.

Webflo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top