7

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.

Trott
  • 66,479
  • 23
  • 173
  • 212
IRHM
  • 1,326
  • 11
  • 77
  • 130

4 Answers4

21
document.getElementById("inputaddress").value = '';
animuson
  • 53,861
  • 28
  • 137
  • 147
Barry Kaye
  • 7,682
  • 6
  • 42
  • 64
4

Would $('#inputaddress').html(""); or document.getElementById('inputaddress').value="" work?

Eamorr
  • 9,872
  • 34
  • 125
  • 209
1
document.getElementById("inputaddress").value = '';
psx
  • 4,040
  • 6
  • 30
  • 59
  • fixed it a second before you posted that comment. jquery comes far more naturally than plain javascript :) – psx Jul 19 '11 at 16:17
0

i am assuming that u id your input address field addr just add this code to the onclick event of your searchforaddress button

document.getElementById('addr').value="";

like this (i am assuming is of ur searchforaddress button is searchforaddress)

    document.getElementById('searchforaddress').onclick=function() {
    document.getElementById('addr').value="";
};
lovesh
  • 5,235
  • 9
  • 62
  • 93
  • All, many thanks for taking the time to reply and for your help and solutions. Kind regards Chris – IRHM Jul 19 '11 at 16:56