views:

23

answers:

2

Hello, I just started in Ajax today and the tutorial i was reading showed me how to use the result to change a div. But is it possible that i can get the result and make it the new value of a text box. This way i can still edit the text box but the current value will be the ajax result.

Right now i am changing the div with this line:

document.getElementById("txtHint").innerHTML=xmlhttp.responseText;

Thanks a lot

+2  A: 
<input type='text' id='mytextbox' />

<script>
// ...
document.getElementById("mytextbox").value=xmlhttp.responseText;
// ...
</script>
sje397
Thanks a lot. Thats it.
Matthew Carter
+1  A: 

Use value instead of innerHTML.

document.getElementById("txtHint").value =xmlhttp.responseText;

ppshein
Thanks a lot. Thats it,
Matthew Carter