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

    Join Date
    Jun 2013
    Posts
    3
    Rep Power
    0

    Java script not working


    I have a html code with java script

    html code contains a dropdown menu with two options Pickup and delivery ...
    If I go for Pickup option everythinig has to be hided.
    If I go for delivery option from drop down
    then Pickup location and the text boxes has to be displayed.

    I dont know where I made the mistake.

    I am able to display html code and the java script is not working...

    Could anyone please let me know what went wrong..

    Code:
    <head>
    <script type="text/javascript">
    $(document).ready(function (){
                    $("#state").change(function() {
                        // foo is the id of the other select box 
                        if ($(this).val() != "Pickup") {
                            $(".foo").show();
                        }else{
                            $(".foo").hide();
                        } 
                    });
                });
    </SCRIPT>
    </head>
    <body>
        <h3> Select Pickup Or Delivery:</h3>
            <p>
                <select id="state" name="state" style="width: 212px;">
                    <option value="Pickup">Pickup</option>
                    <option value="Delivery">Delivery</option>
                </select>
            </p>
    
            <div class="foo" style="display:none;">
    
        <h4> Pickup Location:</h4>
                123 Main St, Edison NJ
            </div>
            <div class="foo" style="display:none;">
                <form>
        <h3> Enter your address below:</h3>
        <label>Address1</label> <input type="text" name="address1"><br>
        <label>Address2</label> <input type="text" name="address2"><br>
        <label>City</label>     <input type="text" name="city"><br>
        <label>State</label>    <input type="text" name="state"><br>
        <label>Zip Code</label> <input type="text" name="zipcode"><br>
            </div>
    
    </body>
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    50
    Rep Power
    35
    Do you have jQuery included in your HTML?
    Code:
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>

IMN logo majestic logo threadwatch logo seochat tools logo