Results 1 to 2 of 2

Thread: How to read from textbox and input number into script .

  1. #1
    Join Date
    Dec 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How to read from textbox and input number into script .

    * Anyone have any advice on the javascript's that grab a number from a a textbox? Need to make var plant able to read from a textbox and put the number from textbox in it.

    Any help is greatly appreciated

    <html>
    <body>

    <script type="text/javascript">
    var plant = "30";

    if (plant == "30"){

    }

    else{document.write("Please make a minnimum order of $30.00.");
    }
    </script>

    </body>
    </html>

  2. #2
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Code:
    $<input type="text" name="total" id="total" />
    Code:
    var plant = document.getElementById("total");
    plant.onchange = function(){
          if(parseFloat(this.value) < 30 || isNaN(parseFloat(this.value))){
                alert("Please make a minimum order of $30");
          } else {
                this.value = parseFloat(this.value);
          }
    };
    Last edited by Nile; 12-29-2011 at 05:01 PM.
    Jeremy | jfein.net

Bookmarks

Posting Permissions

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