Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

dynamic input field generation within the same page at defined location

 
Ackshat Sharma
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
on writing a document.getElementById("id").innerHTML='<input type=\"number\" />';

inside a loop in a javascript function replaces every previous input box by the new one, so no matter the loop prints it n times but it is displayed only once i.e the last printed field

and document.writeln('<input type...>') in the loop prints n fields in a new basic display.

Can anyone here tell me how to dynamically display input fields within the same page at any desired location


Thanks.
 
amit punekar
Ranch Hand
Posts: 544
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
You need to concat the "'<input type=\"number\" />' " to existing innerHTML.
Hence it should be

innerHTML = innerHTML + new input field.


Regards,
Amit
 
Ackshat Sharma
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Amit ,it was useful (and i am laughing on myself).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic