Bugs Happen Bugs Happen - 4 months ago 7
HTML Question

how to change value of textfield of HTML using javascript

<head>
<script type="javascript">
function display()
{
document.getElementById("textField1").value = "abc";
}
</script>
</head>
<body>

<form id="form1" action="http://google.com">

<input id="textField1" type="text" value="0" align="right" size="13"/><br>

<input id="button1" type="button" value="1" onclick="display()">
</form>
</body>


but the value of textfield is not changing.

Any Ideas what am i doing wrong ??

Answer

try

<script type="text/javascript">

instead of

<script type="javascript">

. I believe the latter is not a valid syntax.

Removing the type attribute entirely works as well:

<script>
Comments