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 Link to comment https://forums.phpfreaks.com/topic/213047-javascript-clear-text-box-problem/ 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. Link to comment https://forums.phpfreaks.com/topic/213047-javascript-clear-text-box-problem/#findComment-1109573 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.