Bugs Happen Bugs Happen - 1 year ago 101
HTML Question

how to change value of textfield of HTML using javascript

<script type="javascript">
function display()
document.getElementById("textField1").value = "abc";

<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()">

but the value of textfield is not changing.

Any Ideas what am i doing wrong ??

Answer Source


<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:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download