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???
Probably, because your code remove It ! But we are not soothsayers... A little wraped code (the three last buttons) will be useful !
use [code]YOUR CODE GOES HERE [/code] or burn in Hell
check your code and if your code problem post your code here. and i will find problem in your code
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>
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
Originally Posted by
kfaizan
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!
Originally Posted by
Logic Ali
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
Forum Rules
Bookmarks