Knowledge Walls
Ammu
Hyderabad, Andhra Pradesh, India
Passcode:
Forms in Examples of Javascript 1
1086 Views
EXAMPLE
<!DOCTYPE html>
    <html lang="us-EN">
    <head>
        <meta charset="UTF-8">
        <title>form</title>
        <script>
            function clme()
            {
                alert("hello");
                var firstName=document.getElementById('firstname').value;
                alert(firstName);
                var passWord=document.forms["myForm"]["password"].value;
                alert(passWord);
                var seX=document.forms["myForm"]["sex"].value;
                alert(seX);
                var Languages=document.forms["myForm"]["cpplanguage"].checked;
                alert(Languages);
                var cityName=document.forms["myForm"]["city"].value;
                alert(cityName);
                var  textArea=document.forms["myForm"]["myaddress"].value;
                alert(textArea);
                return false;
            }

        </script>
        
    </head>
    <body>
        
        <form name="myForm" onsubmit="return clme();">
            First Name:<br>
            <input type="text" name="firstname" id="firstname" value="vidhyaa" style="width:100px"><br>
            Password:<br>
            <input type="password" name="password" ><br>
            Sex:<br>
            <input type="radio" name="sex" value="male" checked>Male<br>
            <input type="radio" name="sex" value="female">Female<br>
            Languages:<br>
            <input type="checkbox" name="clanguage" value="c">c<br>
            <input type="checkbox" name="cpplanguage" value="c++">c++<br>
            <input type="checkbox" name="javalanguage" value="Java">Java<br>
            Languages known:<br>
            <select name="city">
                <option value="chennai">chennai</option>
                <option value="salem">salem</option>
            </select>
            <textarea name="myaddress">address here</textarea>
            <input type="submit" value="submit">
            <input type="reset" value="reset">
        </form>
    </body>
</html>

 function showOthers() {
                var currentValue = document.forms["myForm"]["sex"].value;
                if (currentValue == "others") {
                    document.getElementById("sexothers").style.visibility = "visible";
                    document.getElementById("sexothers").focus();
                }
                else {
                    document.getElementById("sexothers").style.visibility = "hidden";
                    document.getElementById("sexothers").value = "";
                }
            }
            
            function firstnamchange() {
                console.log("firstname change: "+document.getElementById("firstname").value);
            }
            
            function fnmouseover() {
                console.log("pwdele fnmouseover: "+document.getElementById("pwdele").value);
            }
            
            function fnmouseout() {
                console.log("pwdele fnmouseout: "+document.getElementById("pwdele").value);
            }

<input type="radio" name="sex" value="male" onclick="showOthers()">Male<br>
            <input type="radio" name="sex" value="female" checked onclick="showOthers()">Female<br>
            <input type="radio" name="sex" value="others" onclick="showOthers()">Others<br>
            <input type="text" name="sexothers" id="sexothers" style="visibility: hidden;"><br>
Next Topics
Next lessons of current book.
Examples of Javascript 1
Previous Topics
Previous lessons of current book.
Examples of Javascript 1
Examples of Javascript 1
Examples of Javascript 1
Examples of Javascript 1
Best Lessons of "Javascript 1"
Top lessons which are viewed more times.
Examples of Javascript 1
Examples of Javascript 1
Examples of Javascript 1
Examples of Javascript 1
Examples of Javascript 1
Examples of Javascript 1
  Copyright © 2014 Knowledge walls, All rights reserved
KnowledgeWalls
keep your tutorials and learnings with KnowledgeWalls. Don't lose your learnings hereafter. Save and revise it whenever required.
Click here for more details