#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    2
    Rep Power
    0

    Need some Help with my program


    Hey guys,
    I have a simple assignment that I cant figure out 1 section. Im puzzled as to why my code does not work. It will not open the appropriate page. This is the following assignment.

    Design a web page where the user is asked to enter the age of the target consumer.
    Code:
     The user is then directed to a new window with the age-appropriate web page to continue the purchasing process.
    After populating the form, the invoice will be displayed.


    The part that i highlighted im having issues with. I got the invoice to work on the other pages. The problem Im having is that when i submit after entering age nada happens. Im lost.

    Here is my code.
    Thanks

    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Ordert</title>
    </head>
    <link rel="stylesheet" href="style.css">

    <!-- Site navigation menu -->
    <ul class="navbar">
    <li><a href="index.html">Home page</a>
    <li><a href="about_us.html">About US</a>
    <li><a href="order.html">Order</a>
    </ul>

    <!-- Site navigation menu -->
    <ul class="navbar">
    <li><a href="index.html">Home page</a>
    <li><a href="about_us.html">About US</a>
    <li><a href="order.html">Order</a>
    </ul>


    <script type = "text/javascript">
    var age_order = 0;
    var total = 0;


    function finish() {

    var myage = document.getElementById("age");
    var number = myage.value;

    if (number < 5 ) {
    document.write("Please Enter Your Age)
    return false;
    if (number < 5 || number > 10) {
    "window.open('kids.html')"
    return false;
    }
    if (10 < number < 15) {
    "window.open('teens.html')"
    return false;
    }
    else if (number > 15) {
    "window.open('adults.html')"
    return false;
    }
    }

    </script>
    </head>

    <h3> Order Form </h3>
    <p>We focus on making the right choice for you based on your age. Please fill in the following window which will take you to the correct age group page. This will allow you to pick the right product.</p>

    <form name = "" onSubmit = "finish()">
    <p>Please enter Your Age <input type = "text" id = "age" size = "8" /> </p>
    </p>
    <p><input type = "reset" name = "reset" />
    <input type = "submit" name = "submit" value="Submit" /></p>
    </form>


    <script type = "text/javascript">

    document.getElementById("age").onchange = ageHandler;


    </script>
    <p style="color: red; margin-left: 10px; text-align: center;">Copyright 2013 </p>


    </body>
    </html>
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    2
    Rep Power
    0
    Originally Posted by alexpilot
    Hey guys,
    I have a simple assignment that I cant figure out 1 section. Im puzzled as to why my code does not work. It will not open the appropriate page. This is the following assignment.

    Design a web page where the user is asked to enter the age of the target consumer.
    Code:
     The user is then directed to a new window with the age-appropriate web page to continue the purchasing process.
    After populating the form, the invoice will be displayed.


    The part that i highlighted im having issues with. I got the invoice to work on the other pages. The problem Im having is that when i submit after entering age nada happens. Im lost.

    Here is my code.
    Thanks

    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Ordert</title>
    </head>
    <link rel="stylesheet" href="style.css">

    <!-- Site navigation menu -->
    <ul class="navbar">
    <li><a href="index.html">Home page</a>
    <li><a href="about_us.html">About US</a>
    <li><a href="order.html">Order</a>
    </ul>

    <!-- Site navigation menu -->
    <ul class="navbar">
    <li><a href="index.html">Home page</a>
    <li><a href="about_us.html">About US</a>
    <li><a href="order.html">Order</a>
    </ul>


    <script type = "text/javascript">
    var age_order = 0;
    var total = 0;


    function finish() {

    var myage = document.getElementById("age");
    var number = myage.value;

    if (number < 5 ) {
    document.write("Please Enter Your Age)
    return false;
    if (number < 5 || number > 10) {
    "window.open('kids.html')"
    return false;
    }
    if (10 < number < 15) {
    "window.open('teens.html')"
    return false;
    }
    else if (number > 15) {
    "window.open('adults.html')"
    return false;
    }
    }

    </script>
    </head>

    <h3> Order Form </h3>
    <p>We focus on making the right choice for you based on your age. Please fill in the following window which will take you to the correct age group page. This will allow you to pick the right product.</p>

    <form name = "" onSubmit = "finish()">
    <p>Please enter Your Age <input type = "text" id = "age" size = "8" /> </p>
    </p>
    <p><input type = "reset" name = "reset" />
    <input type = "submit" name = "submit" value="Submit" /></p>
    </form>


    <script type = "text/javascript">

    document.getElementById("age").onchange = ageHandler;


    </script>
    <p style="color: red; margin-left: 10px; text-align: center;">Copyright 2013 </p>


    </body>
    </html>
    Never mind please Close this. Stupid me forgot the brackets and some quotation marks. All fixed and works

IMN logo majestic logo threadwatch logo seochat tools logo