:: Professional ::
 
You are here: Blog
 

Hilbert Solutions, LLC Latest Dotnetnuke Modules...

Advanced News Ticker        Constant Contact Sign Up

 

Blog
Oct30

Written by:slhilbert
10/30/2009 9:16 AM 

Doing a little javascript these days to handle some presentation changes.  I wanted to convert a State Name spelled out to the state’s abbreviations.  I found a little javascript that got me started and then reworked it from there.

function changeStateAbbr(theValue){ if (theValue == "Alambama"){
document.write("AL");
}
else if (theValue == "Alaska"){
document.write("AK");
}
else if (theValue == "Arizona"){
document.write("AZ");
}
else if (theValue == "Arkansas"){
document.write("AR");
}
else if (theValue == "California"){
document.write("CA");
}
else if (theValue == "Colorado"){
document.write("CO");
}
else if (theValue == "Connecticut"){
document.write("CT");
}
else if (theValue == "Delaware"){
document.write("DE");
}
else if (theValue == "District of Columbia"){
document.write("DC");
}
else if (theValue == "Florida"){
document.write("FL");
}
else if (theValue == "Georgia"){
document.write("GA");
}
else if (theValue == "Hawaii"){
document.write("HI");
}
else if (theValue == "Idaho"){
document.write("ID");
}
else if (theValue == "Illinois"){
document.write("IL");
}
else if (theValue == "Indiana"){
document.write("IN");
}
else if (theValue == "Iowa"){
document.write("IA");
}
else if (theValue == "Kansas"){
document.write("KS");
}
else if (theValue == "Kentucky"){
document.write("KY");
}
else if (theValue == "Louisiana"){
document.write("LA");
}
else if (theValue == "Maine"){
document.write("ME");
}
else if (theValue == "Maryland"){
document.write("MD");
}
else if (theValue == "Massachusetts"){
document.write("MA");
}
else if (theValue == "Michigan"){
document.write("MI");
}
else if (theValue == "Minnesota"){
document.write("MN");
}
else if (theValue == "Mississippi"){
document.write("MS");
}
else if (theValue == "Missouri"){
document.write("MO");
}
else if (theValue == "Montana"){
document.write("MT");
}
else if (theValue == "Nebraska"){
document.write("NE");
}
else if (theValue == "Nevada"){
document.write("NV");
}
else if (theValue == "New Hamspire"){
document.write("NH");
}
else if (theValue == "New Jersey"){
document.write("NJ");
}
else if (theValue == "New Mexico"){
document.write("NM");
}
else if (theValue == "New York"){
document.write("NY");
}
else if (theValue == "North Carolina"){
document.write("NC");
}
else if (theValue == "North Dakota"){
document.write("ND");
}
else if (theValue == "Ohio"){
document.write("OH");
}
else if (theValue == "Oklahoma"){
document.write("OK");
}
else if (theValue == "Oregon"){
document.write("OR");
}
else if (theValue == "Pennsylvania"){
document.write("PA");
}
else if (theValue == "Rhode Island"){
document.write("RI");
}
else if (theValue == "South Carolina"){
document.write("SC");
}
else if (theValue == "South Dakota"){
document.write("SD");
}
else if (theValue == "Tennessee"){
document.write("TN");
}
else if (theValue == "Texas"){
document.write("TX");
}
else if (theValue == "Utah"){
document.write("UT");
}
else if (theValue == "Vermont"){
document.write("VT");
}
else if (theValue == "Virginia"){
document.write("VA");
}
else if (theValue == "Washington"){
document.write("WA");
}
else if (theValue == "West Virginia"){
document.write("WV");
}
else if (theValue == "Wisconsin"){
document.write("WI");
}
else if (theValue == "Wyoming"){
document.write("WY");
}
else if (theValue){
document.write(theValue);
}
}

Tags:

Your name:
Your email:
(Optional) Email used only to show Gravatar.
Your website:
Title:
Comment:
Security Code
Enter the code shown above in the box below
Add Comment  Cancel 
Search Blog
Blog Archive
Terms Of Use| Privacy Statement Hilbert Solutions, LLC Since 2007