skadouche's Profile User Rating: -----

Reputation: 0 Apprentice
Group:
Members
Active Posts:
24 (0.02 per day)
Joined:
07-July 11
Profile Views:
1,430
Last Active:
User is offline Mar 06 2013 10:41 AM
Currently:
Offline

Previous Fields

Country:
US
OS Preference:
Windows
Favorite Browser:
FireFox
Favorite Processor:
Who Cares
Favorite Gaming Platform:
PC
Your Car:
Nissan
Dream Kudos:
0

Latest Visitors

Icon   skadouche has not set their status

Posts I've Made

  1. In Topic: Build a burrito

    Posted 4 Mar 2013

    I have zero javascript experience and have to build the javascript code and dont know where to start/how to code it.
  2. In Topic: javascript checkboxes

    Posted 10 Feb 2013

    
    function validateAll() {
        validateName();
        validateEmail();
        validatePhone();
        validateAddress();
        validateCity();
        validateZip();
        outputUserInfo();
        
    }
    function validateName() {
          if(document.getElementById("txtName").value.length == 0) {
            if(!document.getElementById("nameErrorMessage")) {
            var errorMessage = document.createElement("span");
            errorMessage.id ="nameErrorMessage";
            errorMessage.appendChild(document.createTextNode("Name is required!"))
            document.getElementById("nameSection").appendChild(errorMessage);
            }
        } else {
            var nameError = document.getElementById("nameErrorMessage");
            if(nameError) {
                nameError.parentNode.removeChild(nameError);
            }
        } 
    }
    
    function validateEmail() {
    
        if(document.getElementById("txtEmail").value.length == 0) {
            if(!document.getElementById("emailErrorMessage")) {
            var errorMessage = document.createElement("span");
            errorMessage.id ="emailErrorMessage";
            errorMessage.appendChild(document.createTextNode("Email is required!"))
            document.getElementById("emailSection").appendChild(errorMessage);
            }
        } else {
            var nameError = document.getElementById("emailErrorMessage");
            if(nameError) {
                nameError.parentNode.removeChild(nameError);
            }
        }
    }
    function validatePhone() {
    
        if(document.getElementById("txtPhone").value.length == 0) {
            if(!document.getElementById("phoneErrorMessage")) {
            var errorMessage = document.createElement("span");
            errorMessage.id ="phoneErrorMessage";
            errorMessage.appendChild(document.createTextNode("Phone is required!"))
            document.getElementById("phoneSection").appendChild(errorMessage);
            }
        } else {
            var nameError = document.getElementById("phoneErrorMessage");
            if(nameError) {
                nameError.parentNode.removeChild(nameError);
            }
        }
    }
    function validateAddress() {
    
        if(document.getElementById("txtAddress").value.length == 0) {
            if(!document.getElementById("addressErrorMessage")) {
            var errorMessage = document.createElement("span");
            errorMessage.id ="addressErrorMessage";
            errorMessage.appendChild(document.createTextNode("Address is required!"))
            document.getElementById("addressSection").appendChild(errorMessage);
            }
        } else {
            var nameError = document.getElementById("addressErrorMessage");
            if(nameError) {
                nameError.parentNode.removeChild(nameError);
            }
        }
    }
    function validateCity() {
    
        if(document.getElementById("txtCity").value.length == 0) {
            if(!document.getElementById("cityErrorMessage")) {
            var errorMessage = document.createElement("span");
            errorMessage.id ="cityErrorMessage";
            errorMessage.appendChild(document.createTextNode("City is required!"))
            document.getElementById("citySection").appendChild(errorMessage);
            }
        } else {
            var nameError = document.getElementById("cityErrorMessage");
            if(nameError) {
                nameError.parentNode.removeChild(nameError);
            }
        }
    }
    function validateZip() {
    
        if(document.getElementById("txtZip").value.length == 0) {
            if(!document.getElementById("zipErrorMessage")) {
            var errorMessage = document.createElement("span");
            errorMessage.id ="zipErrorMessage";
            errorMessage.appendChild(document.createTextNode("Zip is required!"))
            document.getElementById("zipSection").appendChild(errorMessage);
            }
        } else {
            var nameError = document.getElementById("zipErrorMessage");
            if(nameError) {
                nameError.parentNode.removeChild(nameError);
            }
        }
    }
    function outputUserInfo() {
        var display = document.getElementById("output");
         if(display) {
            //remove the existing output
            display.parentNode.removeChild(display);
        }
       
        var outputHolder = document.createElement("div");
        outputHolder.id = "output";
        
        var nameText = document.getElementById("txtName").value;
        outputHolder.appendChild(document.createTextNode("Name: " + nameText));
        
        outputHolder.appendChild(document.createElement("br"));
       
        var emailText = document.getElementById("txtEmail").value;
        outputHolder.appendChild(document.createTextNode("Email: " + emailText));
        
        outputHolder.appendChild(document.createElement("br"));
        
        var phoneText = document.getElementById("txtPhone").value;
        outputHolder.appendChild(document.createTextNode("Phone: " + phoneText));
        
        outputHolder.appendChild(document.createElement("br"));
        
        var addressText = document.getElementById("txtAddress").value;
        outputHolder.appendChild(document.createTextNode("Address: " + addressText));
        
        outputHolder.appendChild(document.createElement("br"));
        
        var cityText = document.getElementById("txtCity").value;
        outputHolder.appendChild(document.createTextNode("City: " + cityText));
        
        outputHolder.appendChild(document.createElement("br"));
        
        var stateList = document.getElementById("state");
        var stateText = stateList.options[stateList.selectedIndex].text;
        outputHolder.appendChild(document.createTextNode("State: " + stateText));
        
        outputHolder.appendChild(document.createElement("br"));
        
        var zipText = document.getElementById("txtZip").value;
        outputHolder.appendChild(document.createTextNode("Zip: " + zipText));
        
        outputHolder.appendChild(document.createElement("br"));
        
        var genderText = document.getElementById("male").checked;
        
        if(genderText){
            var genderText = document.getElementById("male").value;
            outputHolder.appendChild(document.createTextNode("Gender: " + genderText));
            outputHolder.appendChild(document.createElement("br"));
        } else {
            var genderText = document.getElementById("female").value;
            outputHolder.appendChild(document.createTextNode("Gender: " + genderText));
            outputHolder.appendChild(document.createElement("br"));
        }
        
        var ckBoxes = document.getElementById("asp").checked;
        
        if(ckBoxes) {
            var ckBoxes = document.getElementById("asp").value;
            outputHolder.appendChild(document.createTextNode("Previous Courses: " + ckBoxes));
        } else {
            var ckBoxes = document.getElementById("java").value;
            outputHolder.appendChild(document.createTextNode("Previous Courses: " + ckBoxes));
        } 
    
       
        document.body.appendChild(outputHolder);
        
    }
    
    


    what i posted first was the html that is involved, then the javascript I haven't really written cause i don't know how to get the output...please help

    If one checkbox is selected output the value and remove the comma at the end
    if two checkboxes are selected output the values and remove the comma at the end
    if all three are selected output the values and remove the comma at the end

    all of this happening when the validate button is clicked

    <html>
        <head>
            <script type="text/javascript" src="validate.js"></script>
            <link type="text/css" rel="stylesheet" href="Project1CSS.css" />
        </head>
        <body>
            <form id="labelDesign">
                <div id="nameSection">
                    <label for="name">Name:</label>
                    <input type="text" id="txtName" />
                </div>
                <div id="emailSection">
                    <label for="email">Email:</label>
                    <input type="text" id="txtEmail" />
                </div>
                <div id="phoneSection">
                    <label for="phone">Phone:</label>
                    <input type="text" id="txtPhone" />
                </div>
                <div id="addressSection">
                    <label for="address">Address:</label>
                    <input type="text" id="txtAddress" />
                </div>
                <div id="citySection">
                    <label for="city">City:</label>
                    <input type="text" id="txtCity" />
                </div>
                <div>
                    <label for="state">State:</label>
                        <select id="state">
                            <option value="Wisconsin">Wisconsin</option>
                            <option value="Minnesota">Minnesota</option>
                            <option value="Ohio">Ohio</option>
                            <option value="Nevada">Nevada</option>
                            <option value="Florida">Florida</option>
                        </select>
                </div>
                
                <div id="zipSection">
                    <label for="zip">Zip:</label>
                    <input type="text" id="txtZip" />
                </div>
                
                <div>
                    <label for="radio">Gender:</label>
                    <input type="radio" name="genders" id="male" value="Male" checked="checked">Male</input>
                    <input type="radio" name="genders" id="female" value="Female">Female</input>
                </div>
                
                <div class="fieldContainer">
                    <label>Previous Courses:</label>
                    <div id="courses">
                        <input type="checkbox" id="asp" value="ASP,">ASP.NET</input><br />
                        <input type="checkbox" id="java" value="AdvancedJava,">Advanced Java</input><br />
                        <input type="checkbox" id="php" value="PHP,">PHP</input>
                    </div>
                </div>
                <br />
                <input type="button" id="btnValidate" onclick="validateAll();" value="validate" />
            </form>
        </body>
    </html>
    
    


    here is all the html

My Information

Member Title:
New D.I.C Head
Age:
18 years old
Birthday:
January 4, 1996
Gender:
Location:
Madison, WI
Interests:
Finishing school so I can get a job!
Years Programming:
2

Contact Information

E-mail:
Click here to e-mail me

Friends

skadouche hasn't added any friends yet.

Comments

skadouche has no profile comments yet. Why not say hello?