Total members 10262 | Gratitudes |It is currently Wed May 23, 2012 8:26 pm Login / Join Codemiles


All times are UTC [ DST ]




Post new topic Reply to topic  Quick reply  [ 1 post ] 
Author Code Snippet
 Code subject: JavaScript switch example
PostPosted: Tue Sep 13, 2011 9:42 pm 
Offline
Mastermind
User avatar

Joined: Tue Mar 27, 2007 10:55 pm
Posts: 2279
Location: Earth
Has thanked: 39 time
Have thanks: 61 time

JavaScript switch example
Code:

<html>
<
head>    
    
<script language="JavaScript" type="text/javascript">  
    function tellMeName
(name){  
        name 
= name.toLowerCase()  
        switch
(name){  
         case 
"Tom":  
          document
.getElementById("nameBox").innerHTML = "It is my name too :)"; 
         break  
         case 
"Ali":  
          document
.getElementById("nameBox").innerHTML = "Oh , i have a friend with same name.";  
         break  
         case 
"Ahmed":  
          document
.getElementById("nameBox").innerHTML = "Hi Ahmed ."  
         break  
         case 
"Joseph":  
          document
.getElementById("nameBox").innerHTML = "Joe,Welcome to our site ";
         break  
         case 
"Ibrahim":   
          document
.getElementById("nameBox").innerHTML = "Ibrahim , i hope you like the site."  
         break  
         default
:  
          document
.getElementById("nameBox").innerHTML = " " + name + " ! good name :)."  
        
}  
    
}  
    </script>
  
</head>  
<body>  
    <form name="input">  
    <input type="text" name="name">  
    </form>  
    <button onclick="tellMeName(document.input.name.value)">Check</button>  
    <br>  
    <span id="nameBox"></span>  
    
</body>
    
</html>

_________________
Currenlty programming with : java , html , php , and javascript . (OCJP-6 certified )


TOP
 Profile Send private message  
Reply with quote  
Post new topic Reply to topic Quick reply  [ 1 post ] 
Quick reply


  

 Similar topics
 JavaScript fade out problem
 javascript read file
 getting gst, pst total to diplay in my javascript form
 switch keyword in c++ usage
 need help with javascript
 Javascript select menu validation issue
 validate age entered as selection box in javascript
 Trim string in JavaScript
 check array contains a value using javascript
 Javascript Multi-dimensional Arrays

All times are UTC [ DST ]


Users browsing similar codes

Users browsing this forum: Google Adsense [Bot] and 1 guest



Jump to:  
Previous Code Snippet | Next Code Snippet 




Home
General Talks
Finished Projects
Code Library
Games
Tutorials

Java
C/C++
C-sharp
php
Script
JSP/Servlets
Ajax
ASP/ASP.net
Google SEO
Database
Communications
Phpbb3 styles
Photoshop tutorials
Flash tutorials
Find a job






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team