Javascript to clear form field on button click

IRHM picture IRHM · Jul 19, 2011 · Viewed 31.4k times · Source

I have a field called 'inputaddress' which a user types address details into, so they can perform a google map geocode.

What I would like to do is when the user clicks on the 'searchfortheaddress' button, it will perform the geocode but will then clear the 'inputaddress' field.

Could someone perhaps tell me please how I can clear the field.

Answer

Barry Kaye picture Barry Kaye · Jul 19, 2011
document.getElementById("inputaddress").value = '';