<div id="input_container" style="height: 150px; border: solid 1px black; padding: 5px;"> <input id="sample_image" type="text" value="url" /> </div> <script type="text/javascript"> document.onclick = function(){ var image = document.getElementById("sample_image").value; var elem = document.getElementById('input_container'); elem.style.backgroundImage = "url(" + image +")"; } </script>