besly98 Posted September 10, 2010 Share Posted September 10, 2010 Hi Al, I have the following code below which will insert a value into a text box on click, but i want to clear the current vale of the input field as it inserts the new value. can anyone help? function populate (inElem) { var el = document.getElementById("country") // display in text box if (el) { // in case 'foo' does not exist el.value += " " + inElem.innerHTML } if (el2) { el2.value += inElem.innerHTML+"\n" } } Thanks in advance Jon Quote Link to comment Share on other sites More sharing options...
Adam Posted September 10, 2010 Share Posted September 10, 2010 Your comments don't really make sense and I have no idea why there's a check for "el2", but you just need to change the assignment parameter from "+=" to "=". "+=" means to append, where as "=" means take the value of. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.