Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Oct 2010
    Posts
    9
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Javascript HELP Clear Entries

    Hi All,
    I need some help with my pizza form! I feel like I did everything correct and for whatever reason cannot get my form to clear!

    Please let me know your thoughts! I'm new to JS and struggling!


    <html>

    <title>Fox's Pizzaria</title>
    <script>
    function doClear()
    {
    document.PizzaForm.customer.value = "";
    document.PizzaForm.address.value = "";
    document.PizzaForm.city.value = "";
    document.PizzaForm.state.value = "";
    document.PizzaForm.zip.value = "";
    document.PizzaForm.phone.value = "";
    document.PizzaForm.email.value = "";

    document.PizzaForm.sizes[0].checked = false;
    document.PizzaForm.sizes[1].checked = false;
    document.PizzaForm.sizes[2].checked = false;
    document.PizzaForm.sizes[3].checked = false;

    document.PizzaForm.toppings[0].checked = false;
    document.PizzaForm.toppings[1].checked = false;
    document.PizzaForm.toppings[2].checked = false;
    document.PizzaForm.toppings[3].checked = false;
    document.PizzaForm.toppings[4].checked = false;
    document.PizzaForm.toppings[5].checked = false;
    document.PizzaForm.toppings[6].checked = false;
    document.PizzaForm.toppings[7].checked = false;
    return;
    }

    function doSubmit()
    {
    alert("Your pizza order has been submitted.");
    return;
    }



    </script>
    </head>

    <body>
    <form name="PizzaForm">
    <h1>Fox's Pizza Parlor</h1>
    <p>
    <h4>Step 1: Enter your name, address, phone number, and email address:</h4>
    <font face="Courier New">
    Name: &nbsp;&nbsp;&nbsp;<input name=:customer" size="50" type="text"><br>
    Address: <input name="address" size="50" type="text"><br>
    City: &nbsp;&nbsp;&nbsp;<input name="city" size="15" type="text">
    State: <input name="state" size="2" type="TEXT">
    Zip: <input name="zip" size="5" type="text"><br>
    Phone: &nbsp;&nbsp;<input name="phone" size="50" type="text"><br>
    Email: <input name="email" size="50" type="text"><br>
    </font>
    </p>

    <p>
    <h4>Step 2: Select the size of pizza you want:</h4>
    <font face="Courier New">
    <input name="sizes" type="radio">Small
    <input name="sizes" type="radio">Medium
    <input name="sizes" type="radio">Large
    <input name="sizes" type="radio">Jumbo<br>
    </font>
    </p>

    <p>
    <h4>Step 3: Select the pizza toppings you want:</h4>
    <font face="Courier New">
    <input name="toppings" type="checkbox">Pepperoni
    <input name="toppings" type="checkbox">Canadanian Bacon
    <input name="toppings" type="checkbox">Sausage<br>
    <input name="toppings" type="checkbox">Mushrooms
    <input name="toppings" type="checkbox">Pineapple
    <input name="toppings" type="checkbox">Black Olives<br>
    <input name="toppings" type="checkbox">Extra Cheese
    <input name="toppings" type="checkbox">Green Peppers<br>
    </font>
    </p>

    <input type="button" value="Submit Order" onClick="doSubmit()">
    <input type="button" value="Clear Entries" onClick="doClear()">


    </form>
    </body>


    </html>

  • #2
    New to the CF scene
    Join Date
    Oct 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Try changing
    document.PizzaForm.toppings[7].checked = false;
    return;
    }
    to
    document.PizzaForm.toppings[7].checked = false;
    return true;
    }

  • #3
    New to the CF scene
    Join Date
    Aug 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    <input name=:customer" size="50" type="text">

    Change above HTML code to:
    <input name="customer" size="50" type="text">


    You javascript function doClear() terminates at first line within the function

    document.PizzaForm.customer.value = "";

    as its unable to find textbox with name "customer".

  • #4
    Regular Coder
    Join Date
    Nov 2007
    Location
    Leeds, UK
    Posts
    514
    Thanks
    24
    Thanked 19 Times in 19 Posts
    Sorry to bring this alive again but can a mod move this out of Post a JavaScript as its a request for help?
    Working towards a Internet where we don't have website just browser applications Kill the Hyper-link and say hello to 3D Games in the browser :)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •