Thursday, December 18, 2008

Test for radio button value in JavaScript

If you would like to test which radio button is selected in JavaScript you must remember that each button always has a value but only one will have a checked value in the same button group. So to find the selected one you must loop through the group and test the checked value ( see function getSelectedRadioButton() ).


function getSelectedRadioButton(buttonGroup)
{
for ( var i = 0; i < buttonGroup.length; i++)
{
if (buttonGroup[i].checked)
{
return buttonGroup[i].value;
}
}
return 0
}


The function above will return the value assigned to the checked radio button, not the positional value i that it is inside the button group.

Function fnAlertRadioButtonChecked() below will display an alert telling you which radio button was selected. This function can be called from an event in the form.


function fnAlertRadioButtonChecked(form)
{
var j = getSelectedRadioButton(form.myButtonGroupName);

if (j == 'first')
{
alert('The radio button assigned a value of first is checked.');
}
else if (j == 'second')
{
alert('The radio button assigned a value of second is checked.');
}
else if (j == 'third')
{
alert('The radio button assigned a value of third is checked.');
}
else
{
alert('The radio button assigned a value of ' & j & ' is checked.');
}

}

Thursday, September 11, 2008

MXUnit

I setup MXUnit and the mxunit eclipse plugins on my local development environment. Tried it out on a couple of CFCs I had built for a project at work. I went through 3 round of tests on one of the CFCs and "walla"!! I found an error. I am sold on testing and MXUnit now. It is really cool to be able to just run these test, each and every time I modify the CFC.

A side note that may or may not effect very many people is a compatibility issue with the software I have installed. My employer decided to use Altiris to manage the migration of Lotus Notes to Outlook and office 2007. Altiris has issues with Eclipse, CFEclipse, Fusebox, MXUnit, CodeCop, etc... Certain XML file parsing will cause our systems to blue screen. The BSOD is usually when you browse the sites that parse certain XML files. Our company is actively troubleshooting this issue, no resolution yet. Fusebox needed a couple of XML files modified. CodeCop has not been fixed yet, BSOD every time.

MXUnit also caused a BSOD when browsing the MXUnit directory. With some help from Adam Haskell at work, there were two XML files found to cause BSOD (mxunit\framework\mxunit-config.xml and mxunit\doc\api\config\config.xml). All we needed to do to stop the BSOD was to remove the comments out of the XML files. This is probably only a bandaid so hopefully we will find the real solution to make Altiris play nice with our setup.

Thursday, July 17, 2008

TODO in CFEclipse

Can't say how much I like the TODO comment feature in CFEclipse. See this article for more info. All you have to do is add "TODO" in a comment and it will appear in your tasks list.


inside scripts .... // TODO: Do this later

No excuse for forgetting stuff now .... unless you forget to use TODO!!

Sunday, July 13, 2008

StructCopy vs Duplicate

Sean Corfield wrote an excellent blog explaining the differences between structCopy(), duplicate(), and normal assignments of structs. Check it out here, http://corfield.org/blog/index.cfm/do/blog.entry/entry/Explaining_StructCopy. This has been confusing for some developers. Bravo Sean!