www.webdeveloper.com
Results 1 to 8 of 8

Thread: Text in Text box disappears !!!

  1. #1
    Join Date
    Jun 2012
    Posts
    6

    Text in Text box disappears !!!

    Aoa,

    i am new and learning Javscript... m making a temperature converter .. why does the result in the texbox dissappear when i click the convert button???

  2. #2
    Join Date
    Oct 2010
    Location
    Versailles, France
    Posts
    1,264
    Probably, because your code remove It ! But we are not soothsayers... A little wraped code (the three last buttons) will be useful !

  3. #3
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,648
    maybe voodoo affected?..
    xxx: Guess Buddhist riddle: "What is the sound of one hand clapping?"
    yyy: facepalm

  4. #4
    Join Date
    Jun 2012
    Posts
    4
    check your code and if your code problem post your code here. and i will find problem in your code

  5. #5
    Join Date
    Jun 2012
    Posts
    6

    Code

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>

    <script type="text/javascript">


    function CFtoC()
    {
    var a=0;
    a = (document.Tform.FtoC1.value -32) * 5/9;
    document.Tform.FtoC2.value = a;
    }
    function CCtoF()
    {
    document.Tform.CtoF2.value = ((document.Tform.CtoF1.value)* 9/5) +32;
    }

    function Reset()
    {
    document.Tform.FtoC1.value = null;
    document.Tform.FtoC2.value = null;
    document.Tform.CtoF1.value = null;
    document.Tform.CtoF2.value = null;

    document.Bform.BA.value= null;
    document.Bform.t15.value= null;
    document.Bform.t25.value= null;
    }

    </script>


    </head>

    <body>

    <h1>Temperature Converter</h1>

    <hr />
    <br />

    <form name="Tform">

    <b>F<b><input type="text" name="FtoC1" />TO<input type="text" name="FtoC2" /><b>C<b>

    <button name="btn1" onclick="CFtoC()">Convert</button>

    <br />
    <b>C<b><input type="text" name="CtoF1" />TO<input type="text" name="CtoF2" /><b>F<b>
    <button name="btn2" onclick="CCtoF()">Convert</button>

    <br />
    <br />

    <button name="R" onclick="Reset()">Reset</button>

    </form>

    </body>
    </html>

  6. #6
    Join Date
    Jun 2012
    Posts
    6

    Code

    When I run it on DreamWeaver it Works perfectly fine ... But When i run it on Chrome,firefox,IE .. The same problem occurs... thanx

  7. #7
    Join Date
    Mar 2007
    Location
    U.K.
    Posts
    1,127
    Quote Originally Posted by kfaizan View Post
    When I run it on DreamWeaver it Works perfectly fine ... But When i run it on Chrome,firefox,IE .. The same problem occurs... thanx
    You need to suppress submission of the form:
    Code:
    onclick="CFtoC();return false"
    or better because it only has to be done once:
    Code:
    <form onsubmit='return false' >
    Where used, return should be executed unconditionally and always as the last statement in the function.

    That's my signature, it's not part of the damn post!

  8. #8
    Join Date
    Jun 2012
    Posts
    6
    Quote Originally Posted by Logic Ali View Post
    You need to suppress submission of the form:
    Code:
    onclick="CFtoC();return false"
    or better because it only has to be done once:
    Code:
    <form onsubmit='return false' >


    Why do we need to return false please explain me what does it do in the inside when we return false... why do we need to suppress submission of the form.??? thanx

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles