   [web] adding HTML with javascript
  I have a quick question which has caused me to waste this entire day trying to do something so stupidly simple it makes me want to impale myself on a rusty pitchfork.I have a function that is called every time I press a button. The function adds a text field to a div tag. After adding it I want to insert the HTML tag < BR>, so that the next field that gets added is on a new line. I can't figure it out how to tell the &#106avascript to write this. Any ideas?This has been a bad week. Based on some code another member donated to mevar num = [0];function add(){var txt = document.createElement("input");txt.setAttribute("type", "text");txt.setAttribute("size", "[40]");txt.id = "spotlight_images" + num;txt.name = "spotlight_images" + num;txt.value = txt.id;document.getElementById('spotlight_images').appendChild(txt);num++;}
  Off the top of my head, I think this should workvar br = document.createElement('br');document.getElementById('spotlight_images').appendChild(br);I'm pretty sure you've tried that, but if not, I hope it works [smile]   ;  oh happy days! THANKYOU GOOD SIR!ARGH! I never heard of the command appendChild [sad]   ;Quote:Original post by booleanARGH! I never heard of the command appendChild [sad]Well, you used that command yourself to add the text fiels. That'll teach you to use someone else's code without understanding what it does [grin];Quote:Original post by SanderQuote:Original post by booleanARGH! I never heard of the command appendChild [sad]Well, you used that command yourself to add the text fiels. That'll teach you to use someone else's code without understanding what it does [grin][grin]