echo " <script> var elem = document.createElement('input') elem.name = ".$name." elem.type = 'text' document.getElementById('somediv').appendChild(elem) </script> ";