var a = document.getElementById('ID1')if(a){document.getElementById('ID2').value=a.innerHTML;} else{document.getElementById('ID2').value=' ';}