Archive for the 'Javascript' Category

So today as I was oh so joyfully finishing up a project, I ran into another fun (but enlightening) Javascript issue.
I have an object, and within that object… I have methods (nothing special there, huh?). So, I figured that since all of this is so prettily encapsulated, I should have no issues adding an event [...]


Oye,
So… I was creating a timepicker like that of Google’s calendar app for a client and lo and behold I ran into a fun yet hard to figure out Javascript problem.
Like a good little girl, I was using parseInt on my integers to ensure it was a proper integer. In this case, I was attempting [...]


Okay, so yesterday I was attempting to finish a lovely page where an administrator can edit emails. I wanted to send the form variables in on submit, but since there are hidden forms due to java script displaying each one separately, I wanted the submit to function with AJAX. This worked fine and dandy until [...]


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 [...]


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 [...]