Never been to TextSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

About this user

« Newer Snippets
Older Snippets »
11 total  XML / RSS feed 

ETS Escaping Parse

ETS will parse anything between {} in order to escape the parse use the following.

{# {escaped code} #}

Javascript Numbers Only

Restrict entering anything but numbers in a form field with javascript

javascript:
<SCRIPT TYPE="text/javascript">

SCRIPT>


html
<FORM ACTION="../cgi-bin/mycgi.pl" METHOD=POST>
U.S. ZIP Code: 
  <INPUT NAME="dollar" SIZE=5 MAXLENGTH=5
   onKeyPress="return numbersonly(this, event)">
  <INPUT TYPE=SUBMIT VALUE="go">
FORM>

Parse/Format Phone Number With ETS

Easy Template System template code to take an unformatted phone number and make it display as (xxx) xxx-xxxx

{if: {php}strlen({phoneNumber}){/php} >= 10}({php}substr({phoneNumber}, -10, 3){/php}) {/if}{php}substr({phoneNumber}, -7, 3){/php}-{php}substr({phoneNumber}, -4){/php}

Load javascript function from returned ajax HTML

Problem - calling a function in

Disable a checkbox

Disable a checkbox via HTML or javascript.

<INPUT TYPE="checkbox" NAME="MyCheckbox" VALUE="Select Me" DISABLED>

document.forms[0].MyCheckbox.disabled = true;

Check / Uncheck all checkboxes in a pseudo group

This bit of javascript will check and uncheck all checkboxes in a group of checkboxes. The checkboxes are grouped by naming all the checkboxes by the same name.

Javascript Code:
function checkUncheckAll(checkAllState, cbGroup)
{
        // Check that the group has more than one element
        if(cbGroup.length > 0)
        {
                // Loop through the array
                for (i = 0; i < cbGroup.length; i++)
                {
                        cbGroup[i].checked = checkAllState.checked;
                }
        }
        else
        {
                // Single element so not an array
                cbGroup.checked = checkAllState.checked;
        }
}


HTML Code:
<input type=checkbox name=checkall onclick="checkUncheckAll(this, grp1);">
<input type=checkbox name=grp1 id=bx1>
<input type=checkbox name=grp1 id=bx2>
<input type=checkbox name=grp1 id=bx3>
<input type=checkbox name=grp1 id=bx4>

Make SymLink In Linux

Makes a symbolic link in linux

ln -s /home/dir_to /home/dir_from

//dir_to is the existing directory you want dir_from to point to symbolically

Disable selecting text in HTML with javascript events

When you need to diable selection of text in a page use the following events in the wrapping tag. This is useful if you use javascript ondblclick and don't want the text to be selected.

onmousedown will stop the selection in Firefox. IE will still select text though so you must also use onselectstart to keep IE from selecting the text.

<td onmousedown="return false;" onselectstart="return false;">
« Newer Snippets
Older Snippets »
11 total  XML / RSS feed