Note that there are some explanatory texts on larger screens.

plurals
  1. POAssingning unique id and names?
    text
    copied!<p>I have a html table with one prototype row. Prototype row has few tds and each td has input element. I am trying to clone the row and assign unique ids and names. But in Fire fox new ids and names are assigned properly. But in IE unique ids and names are not assigned. This logic works fine in FF. But in IE7 it does not work. </p> <h2>html Table:</h2> <pre><code>&lt;table class="myTable"&gt; &lt;tr class="prototype"&gt; &lt;td&gt; &lt;label for="myValue1"&gt;MY Value ONE:&lt;/label&gt;&lt;br&gt; &lt;input class="required email" id="myValue1" type="text" value="" name="myValue1"&gt; &lt;/td&gt; &lt;td&gt; &lt;label for="myValue2"&gt;MY Value TWO:&lt;/label&gt;&lt;br&gt; &lt;input class="required email" id="myValue2" type="text" value="" name="myValue2"&gt; &lt;/td&gt; &lt;td&gt; &lt;label for="myValue3"&gt;MY Value THREE:&lt;/label&gt;&lt;br&gt; &lt;input class="required email" id="myValue3" type="text" value="" name="myValue3"&gt; &lt;/td&gt; &lt;td&gt; &lt;label for="myValue4"&gt;MY Value FOUR:&lt;/label&gt;&lt;br&gt; &lt;input class="required email" id="myValue4" type="text" value="" name="myValue4"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <h2>JQuery code:</h2> <pre><code>$("#new").click(function(e) { e.preventDefault(); var d = new Date(); var counter = d.getTime(); var master = $("table.myTable"); var prot = master.find("tr.prototype").clone(); prot.removeClass('prototype'); prot.addClass("contact"); prot.find("#myValue1").attr('id',"myValue1"+counter); prot.find("#myValue2").attr('id',"myValue2"+counter); prot.find("#myValue3").attr('id',"myValue3"+counter); prot.find("#myValue4").attr('id',"myValue4"+counter); prot.find("#myValue1"+counter).attr('name',"myValue1"+counter); prot.find("#myValue2"+counter).attr('name',"myValue2"+counter); prot.find("#myValue3"+counter).attr('name',"myValue3"+counter); prot.find("#myValue4"+counter).attr('name',"myValue4"+counter); jQuery('table.myTable tr:last').before(prot); }); </code></pre> <p>But with the above code unique ids and names are not assigned.am i doing anything wrong here?</p> <p>Thanks!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload