Archive for June, 2009
Simple JQuery check-all
Simple check all with Jquery:
function checkAll(el, fieldName){
var checkBoxes = $(‘input[name=' + fieldName + ']‘);
var curValue = el.value;
if(curValue == ‘Check All’){
$.each(checkBoxes, function() {this.checked = true});
el.value = ‘Uncheck All’;
} else {
$.each(checkBoxes, function() {this.checked = false});
el.value = ‘Check All’;
}
}
How to use?
Pass in the “this” keyword as the first parameter. Second, pass in the name of the fields that [...]
Filed under: Beginner, Javascript, Jquery | Leave a Comment
Creating a javascript select box with numbered selections in multiples:
var i;
var totalRows = 20;
var selectBox = document.getElementById(‘thisSelect’);
for (i = 1; i < = totalRows; i++ ){
if( (i % 5) == false ){
var newOption = new Option(i, i);
selectBox.options.add(newOption);
}
}
What’s going on?
Initialize variables:
var i;
var totalRows = 20;
var selectBox = document.getElementById(‘thisSelect’);
var newOption;
Loop over total rows:
for (i = 1; i [...]
Filed under: Beginner, Javascript | Leave a Comment
Search
-
You are currently browsing the ✩CodeStar✩ weblog archives for the month June, 2009.