Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 4 of 4
  1. #1
    Junior Member Pxl_Buzzard's Avatar
    Join Date
    Sep 2007
    Posts
    8
    Member #
    15790
    Hey all, I'm trying to build a simple dropdown with zip codes that will display prices for the zip code when selected. I'm having trouble displaying the value of the selected option and I know it's something easy to fix. Here's the code I have so far:

    Code:
      <select id="single">
        <option value="$70">63031</option>
        <option value="$99">63042</option>
      </select>
     <div id="output"></div>
    <script>
    $(document).ready(function(){
        $("#single").change(onSelectChange);
    });
    function onSelectChange(){
        var selected = $("#single option:selected");    
        var price = $("#single option:selected value");            
        var output = "";
        if(selected.val() != 0){
            output = "The price for moving in " + selected.text() + " is" + price;
        }
        $("#output").html(output);
    }
    </script>
    Thanks for the help!

  2.  

  3. #2
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    Code:
    $(document).ready(function(){
        $("#single").change(function(){
            var price = $(this).val();    
            var text = $(this).find(":selected").text();            
            var output = "";
            if(price != 0){
                output = "The price for moving in " + text + " is" + price;
            }
            $("#output").html(output);
        });
    });

  4. #3
    Junior Member Pxl_Buzzard's Avatar
    Join Date
    Sep 2007
    Posts
    8
    Member #
    15790
    Thanks very much smoseley, I really appreciate it.

  5. #4
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    Sure thing


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 10:29 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com