Web Analytics Made Easy -
StatCounter i need help fast.. easy question - CodingForum

Announcement

Collapse
No announcement yet.

i need help fast.. easy question

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • i need help fast.. easy question

    Code:
    <input type="text" name="box">
    <input type="button" value="Add" onClick="cool()">
    
    <script language="JavaScript">
       var blue=5;
       function cool() {
       blue=blue+1;
      
    }
    </script>
    Hey peoople.. this is a simple question.. but i can't get it to work
    If click the button, it will added 1, then assign to blue..

    how do it make it show in "box" text field?
    Do I use return blue=box.value;??
    Help me plzz.. thank you..

  • #2
    function cool() {
    blue=blue+1; //or simply blue++
    document.whateverTheFormNameIs.box.value=blue;
    }
    Glenn
    vBulletin Mods That Rock!

    Comment


    • #3
      Don't know what's the problem. I tried it and it works fine.
      Here's how I test it:

      <input type="text" name="box">
      <input type="button" value="Add" onClick="cool()">
      <input type="button" value="Blue Value" onClick="getblueValue()">

      <script language="JavaScript">
      var blue=5;
      function getblueValue() {
      alert(blue);
      }
      function cool()
      {
      blue=blue+1;
      }

      </script>

      Comment


      • #4
        The question is:
        how do it make it show in "box" text field?
        Glenn
        vBulletin Mods That Rock!

        Comment


        • #5
          Originally posted by glenngv
          function cool() {
          blue=blue+1; //or simply blue++
          document.whateverTheFormNameIs.box.value=blue;
          }

          thank you so much

          Comment


          • #6
            Try this:

            <form name= fm>
            <input type="text" name="box">
            <input type="button" value="Add" onClick="cool()">
            </form>

            <script language="JavaScript">
            var blue=5;
            function cool() {
            blue=blue+1;
            document.fm.box.value = blue
            }
            </script>

            Comment


            • #7
              another quick question

              for that situation.. I can set that it's click added.. and when it's reach 12.. it will stop adding.. how do I that/
              using a math.min()??

              Comment


              • #8
                Originally posted by balljilai
                Try this:

                <form name= fm>
                <input type="text" name="box">
                <input type="button" value="Add" onClick="cool()">
                </form>

                <script language="JavaScript">
                var blue=5;
                function cool() {
                blue=blue+1;
                document.fm.box.value = blue
                }
                </script>
                already suggested.

                VietBoyVS:
                Code:
                function cool() {
                  if (blue<12) {
                     blue++;
                     document.whateverTheFormNameIs.box.value=blue;
                  }
                }
                Glenn
                vBulletin Mods That Rock!

                Comment


                • #9
                  thx again..

                  Comment

                  Working...
                  X