Javascript Toggle All Checkboxes

Here is a nifty little tool I modified to toggle all checkboxes on a page. I use this when displaying a list of files or items that need to be processed on form submit.


<SCRIPT LANGUAGE="JavaScript"&gt
//Toggle all Checkboxes
function toggle_all(x){
//alert('toggle = '+ x);
var inputlist = document.getElementsByTagName("input");
for (i = 1; i < inputlist.length; i++) {
if ( inputlist[i].getAttribute("type") == 'checkbox' ) { // look only at input elements that are checkboxes
if (x == false) inputlist[i].checked = false
else inputlist[i].checked = true;
}
}
}

</script>

Put this above the list of items that have a checkbox. Notice that above I start the counter at 1 rather than zero so it ignores this checkbox.
<input type="checkbox" name="togall" onclick="javascript: toggle_all(this.checked);">

Posted in Code, Javascript, Snippets | Leave a comment

Timex Tide, Temperature, and Compass watch review

I received the Timex Tide, Temperature, and Compass watch for Christmas. It is a heavy chunk of metal on a rubber wrist strap. While this watch sounds cool for the outdoor enthusiast, it should be noted it has a couple of design flaws.

Cons:
1) The temperature gauge is influenced by body temperature and stays around 80 degrees. You have to take off the watch for 5 mins to get a good temperature reading. Timex does not mention this in their marketing.
2) The compass feature needs to be level and still to get a good reading.
3) The tide feature – not so accurate, so if you really want to know High and Low tide consult the internet. Once set it will get you within a few minutes but will require adjusting every few days.
4) calendar feature – like most manual calendar watches you have to reset the date for months that have fewer than 31 days when you cross over to the first.
5) the writing on the inner dials is too small to read. I had to use a magnifying glass.

Pros:
1) Good back lighting when needed
2) is supposedly waterproof but I didn’t want to really test it.
3) It does seem to keep accurate time.

To me it is not worth the money spent. I will likely sell mine for a loss to someone who just likes the look of the watch.

Posted in Randomness, Rants | Leave a comment

CFEmail – Fix

If your link to the SMTP server is occasionally interrupted you will notice that CFEmail will no longer function until CF services are restarted.
While reviewing an article by Ben Nadel he mentioned using an alternate SMTP Server such as GMAIL.
We tried it here at work and found that we could implement a secondary SMTP server and after 10 days have not had any failures in CFEmail.

Posted in Coldfusion, Problems & Fixes | Leave a comment

CFINVOKE Passing parameters by using attribute format

Found this useful today:
You can pass parameters in the cfinvoke tag as tag attribute name-value pairs, as the following example shows. You can also use a relative path to the CFC.

<cfinvoke component="/path/to/authQuery" method="getAuthSecure"
lastName="#session.username#" pwd="#url.password#" />

can also be written as

<cfinvoke component="/path/to/authQuery" method="getAuthSecure">
<cfinvokeargument name="lastName" value="#session.username#">
<cfinvokeargument name="pwd" value="#url.password#">
</cfinvoke>

Posted in Code, Coldfusion, Snippets | Leave a comment

CFLocation – URL redirection

There are times when it is handy to redirect to another CFM or page based upon search results. The issue I had this week was due to uninformed users not knowing which option to choose. So at the beginning of my queries I check to see if they are going down the right path or of they need to be redirected to another path. Rather than throwing an error message like “Hey dummy, you picked the wrong option” I merely redirect them to the correct path.

cfquery (logic to determine if the users selection is correct or not)
<cfif #queryname.recordcount# eq 0>
<cflocation url="newpage.cfm?xvar=xvalue&yvar=yvalue">
</cfif>

Another option would be to do a javascript confirm or CF9 Messagebox asking user to review their selections and continue/cancel.

Posted in Code, Coldfusion, Snippets | Leave a comment