I have a series of buttons created from a database, they are set to active or disabled based on a value in the database.
I am trying to create a script that sees what value the button has and changes it to the other state.
My buttons
<input type='button'
name='activebutton'
id='actbutton11'
value='Active'
class='activebutton'
/>
My script currently looks like this, it is currently unable to differentiated between active and disabled buttons.
I can also get it to change the buttons value but it doesn't change the value of C if the method is called again.
I want the user to be able to call the new appropriate method once a button has changed state.
$(document).ready(function(){
$(".activebutton").click(function(){
var c = $(this).val();
// alert(c)
if(c = "Active")
{
var answer = confirm("Disable button?")
if (answer)
{
var $inputElement = $(this),
$("activebutton").val("Disabled");
}
}
else
{
var answer = confirm("Activate button?")
var $inputElement = $(this),
{
$("activebutton").val("Active");
}
}
});
});