I have this piece of simple code.
<html>
<head>
<script type="text/javascript">
function changeText()
{
var form = document.forms['detail'];
form.desc.value="success";
}
</script>
</head>
<body>
<form name="detail">
<input type="text" name="desc" id="desc" >
<input type="submit" value="changetext" onClick=changeText()>
</form>
</body>
</html>
When i run this in Mozilla browser the value of the textbox named “desc” changes but disappears immediately…i.e it is not shown forever and becomes empty.
How can I fix it.
Regards,
Vijay
Try using:
It looks like your page is refreshing, and that is probably why your field text disappears. If your
onClicklistener returnsfalse, it will prevent this default behaviour.