Set value to input text in JavaScript
Description
The following code shows how to set value to input text.
Example
<html>
<body>
<script language="JavaScript">
function doMath(){<!-- w w w. ja v a 2 s . c o m-->
var inputNum=document.form1.input.value;
var result = inputNum;
document.form1.answer.value = result;
}
</script>
<form name=form1>
<input type="text" name="input" size=10>
<input type="button" value="Calculate" onClick='doMath()'>
<br>
Answer:
<input type="text" name="answer" size=10>
</form>
</body>
</html>
The code above generates the following result.