Getting hidden field data
Getting hidden field data
Hi,
One of my table column consist of a hidden input field and I would like to retrieve it when user click on the expand icon image.
[code]
Apple and Orange
$1.00
[/code]
[code]
$("#tableMain tbody td img").live("click", function( ) {
var nTr = this.parentNode.parentNode;
if( this.src.match('details_close') ) {
this.src = "examples_support/details_open.png";
oTable.fnClose( nTr );
}
else {
this.src = "examples_support/details_close.png";
oTable.fnOpen( nTr, fnFormatDetails(oTable, nTr), 'details' );
}
});
[/code]
How do I retrieve it using the example with var nTr = this.parentNode.parentNode; in order to get the descript field? Any help greatly appreciated.
One of my table column consist of a hidden input field and I would like to retrieve it when user click on the expand icon image.
[code]
Apple and Orange
$1.00
[/code]
[code]
$("#tableMain tbody td img").live("click", function( ) {
var nTr = this.parentNode.parentNode;
if( this.src.match('details_close') ) {
this.src = "examples_support/details_open.png";
oTable.fnClose( nTr );
}
else {
this.src = "examples_support/details_close.png";
oTable.fnOpen( nTr, fnFormatDetails(oTable, nTr), 'details' );
}
});
[/code]
How do I retrieve it using the example with var nTr = this.parentNode.parentNode; in order to get the descript field? Any help greatly appreciated.
This discussion has been closed.
Replies
this (the image being clicked) -> get the parent (a TD) -> get the TD's parent (a TR). So nTr is a table row.
If you want to select the input, youcould use a jQuery selector. In your markup you're not showing the image tag, but let me pretend for a moment that it is inside the same TD as the input:
[code]
var myField = $(this).next('input');
myField.val(); // if you want the value of the input, you could do it this way
[/code]
Is the input actually in a form? If it's just the description you need, there are better ways to store it. For example, in the "title" attribute of the TD. In fact, if it's in the title attribute, you can use any number of "tooltip" plugins for displaying this extra information on hover or on click. It really just depends on what your ultimate goal is.