Keep font color selected when button was clicked
Keep font color selected when button was clicked
martin1223345
Posts: 84Questions: 23Answers: 0
I used a onclick function in php to keep the button font color colored after it was clicked. I am trying to aply this in my Datatable row but i get Uncaught SyntaxError: Unexpected identifier. Is this posible and if so how?
The code i used in PHP:
<input type="submit" value="Login" style="width:57px !important;" class="example_e"
onClick="mobLogin('$row['id']',this.style.color='gold');"/>
The code i am trying in Datatables:
{ 'data': null, title: '', wrap: true, "render": function (item) { return '<input type="submit" value="Login" style="width:57px !important;" class="example_x" onClick="mobLogin(' + item.id + ',this.style.color=gold)">' } },
This discussion has been closed.
Answers
I don't see any errors in the above code. in fact I made a test case for you and copied it here. Also reformatted it so its easier to read by placing each option on one line:
http://live.datatables.net/rafumudu/2/edit
Sounds like you have a syntax error somewhere else in your code. Can you post a link to your page or a test case showing the syntax error? Without that we won't be able to help because we need to see the error. Its not a logic error.
Kevin
I should also mention the recommended way to create events with Datatables is to use delegated events, instead of DOM events (onClick), as documented in this faq and this example.
Kevin
Thanks. The error is in the onclick event and particularly the this.style.color
I read your comment and the example. As i am new to javascript the example did not make sence to me. The onclick is used to activate other javascripts. Can you tell me how my code should look like to call the moblogin function with id?
To be exact. The color gold is giving the syntax error
If you want help with this please post a link to your page or a test case replicating the issue. You can update my test case. Maybe the syntax error is in the
mobLogin()
function.This example shows the use of delegated events with buttons and how to get the row data from the clicked buttons:
http://live.datatables.net/xijecupo/1/edit
Kevin