Buttons Plus & Minus
How to increment or decrement a form field using jQuery, specially useful for quantity fields.
HTML
<table class="vuln-table">
<tr role="row" class="even">
<td class="sorting_1"><input checked="true" type="checkbox" name="asfasdfd" id="vuln_checked_" value="asdfsdfa"></td>
<td>something</td>
<td><select class="form-control" name="test" id="kjhtkjehtehr"><option value="Severe">Severe</option>
<option value="High">High</option>
<option value="Medium">Medium</option>
<option selected="selected" value="Low">Low</option>
<option value="Informational">Informational</option>
</select>
</td>
<td></td>
</tr>
</table>
CSS
#myform {
text-align: center;
padding: 5px;
border: 1px dotted #ccc;
margin: 2%;
}
.qty {
width: 40px;
height: 25px;
text-align: center;
}
input.qtyplus {
width: 25px;
height: 25px;
}
input.qtyminus {
width: 25px;
height: 25px;
}
JavaScript
function change_severity(severity) {
$(".vuln-table tr").each(function() {
$(this).find('td input:checked').each(function() {
$(this).parent().parent().find("select").val(severity);
});
});
}
change_severity("Severe")