Disable button onclick but enable another button
You should write functions:
function disablefirstbutton() {
document.getElementById("firstbutton").disabled = true;
document.getElementById("secondbutton").disabled = false;
}
function disablesecondbutton() {
document.getElementById("secondbutton").disabled = true;
document.getElementById("firstbutton").disabled = false;
}
<button id="firstbutton" onclick="disablefirstbutton()">
<button id="secondbutton" onclick="disablesecondbutton()">
If you don't mind using jQuery, here it is!
$(function() {
$('button').click(function() {
var classname = $(this).attr('class');
if(classname == 'positive')
{
$('button.positive').attr('disabled', 'disabled');
$('button.negative').attr('disabled', false);
}
else
{
$('button.negative').attr('disabled', 'disabled');
$('button.positive').attr('disabled', false);
}
});
});
Check this code, it's in your flavour and working:
Code Snippet -
<button
onclick="this.disabled=true;document.getElementById('down7913').disabled=false;"
type="submit"
class="positive"
name="up7913"
id="up7913"
>
First
</button>
<button
onclick="this.disabled=true;document.getElementById('up7913').disabled=false;"
type="submit"
class="negative"
name="down7913"
id="down7913"
>
Second
</button>