onClick change button style / class
onClick change button style / class
dano_wpg
Posts: 1Questions: 0Answers: 0
First post - thanks Allan for making such a great tool!
I'd like to change the buttons so that once clicked, the style changes.
I have set up TableTools with buttons when clicked add to the search criteria. I.e. button "1" when clicked will search for "1" and button "2" when clicked will search for "2". When they are both clicked it will search for "1 2" (one and two).
Ideally when "1" is clicked, the style is changed to "red". When it is clicked again it will revert back to default.
I can see the HTML, and maybe I'd just need to figure out JavaScript more to figure this out (I'm a JavaScript novice).
[code]
1
2
[/code]
But my attempt just doesn't work. Perhaps I'm just missing something. I know the purpose of this line is to only set the color once, but it won't even do that:
[code]
"aButtons": [ {
"sExtends": "text",
"sButtonText": "Collaboration",
"fnClick": function ( nButton, oConfig, oFlash ) {
document.getElementById('ToolTables_tool_0').style.backgroundColor = "#660000";
aToolSearch.push("1");
oTable.fnFilter(aToolSearch.join(" "), 1, false);
oTable.fnDraw();
}
}
[/code]
I'd like to change the buttons so that once clicked, the style changes.
I have set up TableTools with buttons when clicked add to the search criteria. I.e. button "1" when clicked will search for "1" and button "2" when clicked will search for "2". When they are both clicked it will search for "1 2" (one and two).
Ideally when "1" is clicked, the style is changed to "red". When it is clicked again it will revert back to default.
I can see the HTML, and maybe I'd just need to figure out JavaScript more to figure this out (I'm a JavaScript novice).
[code]
1
2
[/code]
But my attempt just doesn't work. Perhaps I'm just missing something. I know the purpose of this line is to only set the color once, but it won't even do that:
[code]
"aButtons": [ {
"sExtends": "text",
"sButtonText": "Collaboration",
"fnClick": function ( nButton, oConfig, oFlash ) {
document.getElementById('ToolTables_tool_0').style.backgroundColor = "#660000";
aToolSearch.push("1");
oTable.fnFilter(aToolSearch.join(" "), 1, false);
oTable.fnDraw();
}
}
[/code]
This discussion has been closed.