Solved

Write input field using InnerHTML

Posted on 2008-10-16
2
452 Views
Last Modified: 2012-05-05
Hi Experts,

I'm having problems with the script below, i am trying to write the contents of the loop to the <td id="909"> tag. But nothing happens and the script is behaving very strangely. Just needed some advice on how to approach this.
<html>
 
<script>
 
function listing() {
   var user_id = "1##2##3##4##5##6##7##8##9##10";
   var a = user_id.match(/[^#]+/g);
   document.open();
   for (var index = 0; index < a.length; index++)
   {
      document.getElementByid('909').innerHTML = ("<input name='" + a[index] + "' value='" + a[index] + "'>");
   }
   document.close();
 
   }
</script>
 
 
 
<body>
<a href="#" onclick="listing();return false;">test</a>
<table><tr><td id="909"></td></tr></table>
</body>
</html>

Open in new window

0
Comment
Question by:agulaid
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 4

Accepted Solution

by:
sijishJohn earned 500 total points
ID: 22729316
change your script like this...
function listing() {
   var user_id = "1##2##3##4##5##6##7##8##9##10";
   var a = user_id.match(/[^#]+/g);  
       for (var index = 0; index < a.length; index++)
       {
          document.getElementById('909').innerHTML += "<input name='" + a[index] + "' value='" + a[index] + "'>";
       } 
   }

Open in new window

0
 

Author Closing Comment

by:agulaid
ID: 31506654
Perfect
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Handling case and special names in javascript 3 24
Sending ASP to server side 8 32
links not working 2 27
JS to redirect to prev page 8 25
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question