IWETHEY v. 0.3.0 | TODO
1,095 registered users | 0 active users | 0 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New This:

var a = Number(document.getElementById("txtBoxA").value || 0);
var b = Number(document.getElementById("txtBoxB").value || 0);
var c = Number(document.getElementById("txtBoxC").value || 0);

And as one of those annoying Chief Software Architect types of malcontents I also need to say things like this:

1) Best practice is to attach a listener to an element in a separate script file, and put the rest of the code in the file as well. Don't use onchange and other inline code unless you absolutely can't avoid it.

2) Use namespaces. Although it may be unlikely that anyone else has a function named "UpdatePOBTotal", it's not impossible. Better to do something like this:

window.MyNamespace = {};
MyNamespace.updatePOBTotal = function()
{
...
}

// And then in the call to it:
MyNamespace.updatePOBTotal();

3) Don't name your functions like classes. Classes start with uppercase, functions start with lowercase.

4) It's also a good idea to keep your references instead of calling getElementById all the time:

// during initialization
MyNamespace.txtBoxA = document.getElementById("txtBoxA");

// later on in the function
var a = MyNamespace.txtBoxA.value;
Regards,
-scott
Welcome to Rivendell, Mr. Anderson.
New Have I mentioned lately ...
... how glad I am that I no longer have to deal with this class of minutia on a daily basis?
--

Drew
     Javascript sucks today - (lincoln) - (9)
         From StackOverflow - (drook)
         This: - (malraux) - (1)
             Have I mentioned lately ... - (drook)
         forgot to add - (lincoln) - (5)
             That's what this is for: - (malraux) - (4)
                 thanks. one question tho - (lincoln) - (3)
                     scope and execution... - (folkert)
                     It makes for tidier code. - (static)
                     Avoids name collisions. - (malraux)

Crazy moon-lovers!
49 ms