New to SO and javascript. I have been playing with JQuery for a couple of days now and I have a problem that I can’t seem to solve. I have absolutely no js experience at all so if someone could help me out by literally spelling out what the issue is, I’d be gratful.
I have a single group of radio buttons that will determine if a user is an administrator or a user. I probably have my html messed up also but what I need is the current ticked value so I can save it to a database. If the user is an administrator, the value will be 1 and if he is a user, the val will be 0.
Here is my html:
<tr> <td class='admMarker'><label for='admEmpIsAdmin'>Admin</label> <input type='radio' id='admEmpIsAdmin' name='status' value='1' checked='checked' class='admChkbx'></td> <td class='admMarker'><label for='admEmpIsUser'>User</label> <input type='radio' id='admEmpIsUser' name='status' value='0' class='admChkbx'></td> </tr>
Here is the javascript:
var admEmpIsAdmin = $('input#admEmpIsAdmin').val();
Can someone please tell me what I am doing wrong here? This code outputs the POST vals but I would also like to know if anyone has any suggestion for me on how to display the current status from the values when they come out of the database.
Thanks!
Try this: