SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist lance_vincent's Avatar
    Join Date
    Aug 2004
    Location
    philippines
    Posts
    574
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Simple javascript

    ok guys, i have 2 textbox, now the first textbox will recieve an input, numbers only..then the second textbox displays a computed value, actually to be multiplied by a number that i will configure.. for now we can use '2'.

    so thats it..when the first textbox recieves a non-numeric input, it will not be displayed, i think something like return false. but if numeric..this will be multiplied by 2, then displays on the second textbox.

    simple isnt it..but for a javascript-super-noob who havent got any idea how it works because i dont know a thing about their properties..i really cant try..i dont know even where to start..

    please help guys!!
    If you won't dress like the
    Victoria Secret girls,
    don't expect us to act like soap opera guys.

  2. #2
    SitePoint Zealot sajjad's Avatar
    Join Date
    May 2005
    Posts
    174
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i am sending u javascript code and html code

    <script language="javascript">
    function dothis()
    {
    if (parseInt(document.form1.first.value) !=document.form1.first.value) {
    alert("numbers only");
    document.form1.first.value = "";

    }
    else
    {
    document.form1.second.value = document.form1.first.value *2;

    }
    }
    </script>

    and html code is
    <form name="form1" method="post" action="">
    <input name="first" type="text" id="first" onChange="dothis()">

    <input name="second" type="text" id="second">

  3. #3
    SitePoint Evangelist lance_vincent's Avatar
    Join Date
    Aug 2004
    Location
    philippines
    Posts
    574
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks a lot for the tutorial..but one more thing man..i hope im not being too much..but i need it as the user types the values, no need to hit "Enter". if its a non-numeric caracter, the value will not enetr the inputbox..but if its a numeric value, it will append to whatever value the inputbox already has.
    If you won't dress like the
    Victoria Secret girls,
    don't expect us to act like soap opera guys.


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
  •