title: How to pass parameter a in the newElement.setAttribute in JavaScript
body: <p>I am using this code to generate the textbox dynamically by using the JavaScript. It's working fine. But my issue is all generated textboxes have the same name. Is there is possible to prefix the textbox count with the textbox' name so that it is easy to post the textbox values?</p>
  
  <pre><code>&lt;html&gt;
        &lt;head&gt;
          &lt;script&gt;//addElement('INPUT','targetTag',{'id':'my_input_tag', 'name':'my_input_tag', 'type':'text', 'value':'txt2','size':'5'}); return false;
            function addElement(tag_type, target, parameters) {
             // var parameters = "'id':'my_input_tag', 'name':'my_input_tag', 'type':'text', 'value':'txt2'";
              //alert(parameters);
              var newElement = document.createElement(tag_type);
  
              //Add parameters
              if (typeof parameters != 'undefined') {
                for (parameter_name in parameters) {
                 // newElement.setAttribute(parameter_name, parameters[parameter_name]);
                     newElement.setAttribute("text","button","name:my_input_tag","value:my_input_tag");
  
                }
              }
  
              //Append element to target
              document.getElementById(target).appendChild(newElement);
  
              if(document.getElementById('txthidden').value == "") { 
              document.getElementById('txthidden').value = 1;
              } else {
              document.getElementById('txthidden').value = parseInt(document.getElementById('txthidden').value) + parseInt(1);
              }
           }
  
            function Submit() {
            var txtval = document.getElementById('my_input_tag').value;
              alert(txtval);
            }
          &lt;/script&gt;
        &lt;/head&gt;
        &lt;body&gt;
          &lt;form method="post"&gt;
          &lt;div id="targetTag"&gt;&lt;/div&gt;
          &lt;input type="submit" value="Check"/&gt;
          &lt;/form&gt;
          &lt;input type="text" name="txthidden" id="txthidden" &gt;
  
          &lt;input type="button" onClick="addElement('INPUT','targetTag',{'id':'my_input_tag1', 'name':'my_input_tag', 'type':'text', 'value':'txt2','size':'5'}); return false;" value="Add Input Tag" /&gt;
  
          &lt;input type="button" onClick="addElement('INPUT','targetTag'); return false;" value="Add Input Tag W/O Parameters" /&gt;
          &lt;input type="button" onClick="return Submit();" value="Save" /&gt;
        &lt;/body&gt;
      &lt;/html&gt;
  </code></pre>