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!)

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

Country dropdown HTML

<select>
<option value="AF">Afghanistanoption>
/option>
<option value="AL">Albaniaoption>
/option>
<option value="AS">American Samoaoption>
/option>
<option value="AO">Angolaoption>
/option>
<option value="AQ">Antarcticaoption>
/option>
<option value="AR">Argentinaoption>
/option>
<option value="AW">Arubaoption>
/option>
<option value="AT">Austriaoption>
/option>
<option value="BS">Bahamasoption>
/option>
<option value="BD">Bangladeshoption>
/option>
<option value="BY">Belarusoption>
/option>
<option value="BZ">Belizeoption>
/option>
<option value="BM">Bermudaoption>
/option>
<option value="BO">Boliviaoption>
/option>
<option value="BW">Botswanaoption>
/option>
<option value="BR">Braziloption>
/option>
<option value="BN">Brunei Darussalamoption>
/option>
<option value="BF">Burkina Fasooption>
/option>
<option value="KH">Cambodiaoption>
/option>
<option value="CA">Canadaoption>
/option>
<option value="KY">Cayman Islandsoption>
/option>
<option value="TD">Chadoption>
/option>
<option value="CN">Chinaoption>
/option>
<option value="CC">Cocos (Keeling) Islandsoption>
/option>
<option value="KM">Comorosoption>
/option>
<option value="CD">Congo, The Democratic Republic Of Theoption>
/option>
<option value="CR">Costa Ricaoption>
/option>
<option value="HR">Croatiaoption>
/option>
<option value="CY">Cyprusoption>
/option>
<option value="DK">Denmarkoption>
/option>
<option value="DM">Dominicaoption>
/option>
<option value="EC">Ecuadoroption>
/option>
<option value="SV">El Salvadoroption>
/option>
<option value="ER">Eritreaoption>
/option>
<option value="ET">Ethiopiaoption>
/option>
<option value="FO">Faroe Islandsoption>
/option>
<option value="FI">Finlandoption>
/option>
<option value="GF">French Guianaoption>
/option>
<option value="TF">French Southern Territoriesoption>
/option>
<option value="GM">Gambiaoption>
/option>
<option value="DE">Germanyoption>
/option>
<option value="GI">Gibraltaroption>
/option>
<option value="GL">Greenlandoption>
/option>
<option value="GP">Guadeloupeoption>
/option>
<option value="GT">Guatemalaoption>
/option>
<option value="GN">Guineaoption>
/option>
<option value="GY">Guyanaoption>
/option>
<option value="HM">Heard Island And Mcdonald Islandsoption>
/option>
<option value="HN">Hondurasoption>
/option>
<option value="HU">Hungaryoption>
/option>
<option value="IN">Indiaoption>
/option>
<option value="IR">Iran, Islamic Republic Ofoption>
/option>
<option value="IE">Irelandoption>
/option>
<option value="IL">Israeloption>
/option>
<option value="JM">Jamaicaoption>
/option>
<option value="JE">Jerseyoption>
/option>
<option value="KZ">Kazakhstanoption>
/option>
<option value="KI">Kiribatioption>
/option>
<option value="KR">Korea, Republic Ofoption>
/option>
<option value="KG">Kyrgyzstanoption>
/option>
<option value="LV">Latviaoption>
/option>
<option value="LS">Lesothooption>
/option>
<option value="LY">Libyan Arab Jamahiriyaoption>
/option>
<option value="LT">Lithuaniaoption>
/option>
<option value="MO">Macaooption>
/option>
<option value="MG">Madagascaroption>
/option>
<option value="MY">Malaysiaoption>
/option>
<option value="ML">Malioption>
/option>
<option value="MH">Marshall Islandsoption>
/option>
<option value="MR">Mauritaniaoption>
/option>
<option value="YT">Mayotteoption>
/option>
<option value="FM">Micronesia, Federated States Ofoption>
/option>
<option value="MC">Monacooption>
/option>
<option value="MS">Montserratoption>
/option>
<option value="MZ">Mozambiqueoption>
/option>
<option value="NA">Namibiaoption>
/option>
<option value="NP">Nepaloption>
/option>
<option value="AN">Netherlands Antillesoption>
/option>
<option value="NZ">New Zealandoption>
/option>
<option value="NE">Nigeroption>
/option>
<option value="NU">Niueoption>
/option>
<option value="MP">Northern Mariana Islandsoption>
/option>
<option value="OM">Omanoption>
/option>
<option value="PW">Palauoption>
/option>
<option value="PA">Panamaoption>
/option>
<option value="PY">Paraguayoption>
/option>
<option value="PH">Philippinesoption>
/option>
<option value="PL">Polandoption>
/option>
<option value="PR">Puerto Ricooption>
/option>
<option value="RE">Reunionoption>
/option>
<option value="RU">Russian Federationoption>
/option>
<option value="SH">Saint Helenaoption>
/option>
<option value="LC">Saint Luciaoption>
/option>
<option value="VC">Saint Vincent And The Grenadinesoption>
/option>
<option value="SM">San Marinooption>
/option>
<option value="SA">Saudi Arabiaoption>
/option>
<option value="CS">Serbia And Montenegrooption>
/option>
<option value="SL">Sierra Leoneoption>
/option>
<option value="SK">Slovakiaoption>
/option>
<option value="SB">Solomon Islandsoption>
/option>
<option value="ZA">South Africaoption>
/option>
<option value="ES">Spainoption>
/option>
<option value="SD">Sudanoption>
/option>
<option value="SJ">Svalbard And Jan Mayenoption>
/option>
<option value="SE">Swedenoption>
/option>
<option value="SY">Syrian Arab Republicoption>
/option>
<option value="TJ">Tajikistanoption>
/option>
<option value="TH">Thailandoption>
/option>
<option value="TG">Togooption>
/option>
<option value="TO">Tongaoption>
/option>
<option value="TN">Tunisiaoption>
/option>
<option value="TM">Turkmenistanoption>
/option>
<option value="TV">Tuvaluoption>
/option>
<option value="UA">Ukraineoption>
/option>
<option value="GB">United Kingdomoption>
/option>
<option value="UM">United States Minor Outlying Islandsoption>
/option>
<option value="UZ">Uzbekistanoption>
/option>
<option value="VE">Venezuelaoption>
/option>
<option value="VG">Virgin Islands, Britishoption>
/option>
<option value="WF">Wallis And Futunaoption>
/option>
<option value="YE">Yemenoption>
/option>
<option value="ZW">Zimbabweoption>
</select>

50 states dropdown HTML

<select name="state">
<option value="">Pick your stateoption>
/option>
<option value="AK">Alaskaoption>
/option>
<option value="AR">Arkansasoption>
/option>
<option value="CO">Coloradooption>
/option>
<option value="DE">Delawareoption>
/option>
<option value="FL">Floridaoption>
/option>
<option value="HI">Hawaiioption>
/option>
<option value="IL">Illinoisoption>
/option>
<option value="IA">Iowaoption>
/option>
<option value="KY">Kentuckyoption>
/option>
<option value="ME">Maineoption>
/option>
<option value="MA">Massachusettsoption>
/option>
<option value="MN">Minnesotaoption>
/option>
<option value="MO">Missourioption>
/option>
<option value="NE">Nebraskaoption>
/option>
<option value="NH">New Hampshireoption>
/option>
<option value="NM">New Mexicooption>
/option>
<option value="NC">North Carolinaoption>
/option>
<option value="OH">Ohiooption>
/option>
<option value="OR">Oregonoption>
/option>
<option value="RI">Rhode Islandoption>
/option>
<option value="SD">South Dakotaoption>
/option>
<option value="TX">Texasoption>
/option>
<option value="VT">Vermontoption>
/option>
<option value="WA">Washingtonoption>
/option>
<option value="WI">Wisconsinoption>
/option>
select>

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>

appendInputTypeClasses() - IE attribute selectors for form inputs

(Stolen from Jeremy Keith and Dustin Diaz: http://domscripting.com/blog/display/38).

Unobtrusive script takes a form inputs type attribute and copies it to that input's class. So, you go from...

<input type="text" />


...to...

<input type="text" class="text" />


Basically allows attribute selectors for form until IE catches up.

/*
        form.js
        AUTH: Austin Govella ([email protected])
        DATE: 2006-07-01
        DESC: Includes form specific javascripts.
        NOTE: Stolen from Jeremy Keith and Dustin Diaz: http://domscripting.com/blog/display/38
        REVS:  
*/



function appendInputTypeClasses()
{       /* adds input type as the inputs class */
        if ( !document.getElementsByTagName ) return;

        var inputs = document.getElementsByTagName('input');
        var inputLen = inputs.length;
        for ( i=0; i < inputLen; i++ )
        {
                if ( inputs[i].getAttribute('type') )
                {
                        inputs[i].className += ' '+inputs[i].getAttribute('type');
                }
        }
}

Javascript clear and recall default form value

// Swap out default text in a form field on click, and recall if field is empty

<script type="text/javascript">
function clickclear(thisfield, defaulttext, color) {
        if (thisfield.value == defaulttext) {
                thisfield.value = "";
                if (!color) {
                        color = "000000";
                }
                thisfield.style.color = "#" + color;
        }
}
function clickrecall(thisfield, defaulttext, color) {
        if (thisfield.value == "") {
                thisfield.value = defaulttext;
                if (!color) {
                        color = "cccccc";
                }
                thisfield.style.color = "#" + color;
        }
}
script>

Javascript clear and recall default form value

// Swap out default text in a form field on click, and recall if field is empty
// Example:

<script type="text/javascript">
function clickclear(thisfield, defaulttext, color) {
        if (thisfield.value == defaulttext) {
                thisfield.value = "";
                if (!color) {
                        color = "000000";
                }
                thisfield.style.color = "#" + color;
        }
}
function clickrecall(thisfield, defaulttext, color) {
        if (thisfield.value == "") {
                thisfield.value = defaulttext;
                if (!color) {
                        color = "cccccc";
                }
                thisfield.style.color = "#" + color;
        }
}
script>

Javascript clear and recall default form value

// Swap out default text in a form field on click, and recall if field is empty
// Example:

<script type="text/javascript">
function clickclear(thisfield, defaulttext, color) {
        if (thisfield.value == defaulttext) {
                thisfield.value = "";
                if (!color) {
                        color = "000000";
                }
                thisfield.style.color = "#" + color;
        }
}
function clickrecall(thisfield, defaulttext, color) {
        if (thisfield.value == "") {
                thisfield.value = defaulttext;
                if (!color) {
                        color = "cccccc";
                }
                thisfield.style.color = "#" + color;
        }
}
script>
« Newer Snippets
Older Snippets »
7 total  XML / RSS feed