asp.net mvc - Iterating through generic collection using jquery or javascript -
i have view dynamically creates table structure
<div> @if (model.parameterlistforreviewerone != null) { foreach (var item in model.parameterlistforreviewerone) { if (item.parmid != null && item.parmid != 0) { <tr class="highlightred parameterofreviewer1 bluebgtable-confi"> <td style="display: none">@html.hiddenfor(modelitem => item.parmid) </td> <td align="center" width="25%"> @html.displayfor(modelitem => item.parameterdesc, new { @readonly = "readonly" }) </td> <td align="center" class="one" width="35%"> @*@html.textboxfor(modelitem => item.reviewer1ratings, new { @class = "revieweroneclass", @id = "ratings1_" + @item.parmid })*@ @html.dropdownlistfor(model => item.reviewer1ratings, new selectlist(model.ratingslist, item.reviewer1ratings), new { @class = "revieweroneclass hideinprint", @id = "ratings1_" + @item.parmid }) <span class="showinprint" id="forprintratings1_@item.parmid">dummy</span> <span style="color: #e80c4d; display: none;" class="hide" id="span_reviewer1rating_@item.parmid"> invalid range.</span> <span style="color: #e80c4d; display: none;" class="hide" id="span_reviewer1ratingrequired_@item.parmid"> required</span> </td> <td align="center" class="one" height="80px" width="40%"> @html.textareafor(modelitem => item.reviewer1comments, new { @class = "reviewercommentsclass requiredfield disablereviewer1 reviewer1parafieldlimit hideinprint", @id = "comments1_" + @item.parmid }) <div class="showinprint" id="comments1_@item.parmid"> dummy</div> <span style="color: #e80c4d; display: none;" class="hide hidecomments1_@item.parmid" id="span_reviewer1commentsrequired_@item.parmid"> required</span> <span id="spn_comments1_@item.parmid" class="classsec3fieldlimit" style="display: none"> </span> </td> </tr> } } } <tr class="bluebgtable-confi"> <td align="center" width="25%"> overall ratings </td> <td align="center" id="overallrating1" valign="middle" height="60px" width="35%"> @* @html.textboxfor(model => model.reviewer1overallrating)*@ @html.dropdownlistfor(model => model.reviewer1overallrating, new selectlist(model.ratingslist), new { @class = "hideinprint" }) <span class="showinprint" id="forprintreviewer1overallrating">dummy</span> <span style="color: #e80c4d; display: none;" class="hide" id="span_overallratingreviewer1"> invalid range.</span> <span style="color: #e80c4d; display: none;" class="hide" id="span_overallratingreviewer1required"> required</span> </td> <td id="overallrating1" align="center" class="requiredfield" height="80px" width="40%">@html.textareafor(model => model.reviewer1overallratingcomments, new { @class = "disablereviewer1 hideinprint" }) <div class="showinprint" id="forprintreviewer1overallratingcomments"> dummy</div> <p>@html.validationmessagefor(model => model.reviewer1overallratingcomments)</p> <span style="color: #e80c4d; display: none;" class="hide hideoverallrating1" id="span_reviewer1overallratingcommentsrequired"> required</span> </td> </tr> </div>
in javascript function want parmid dynamically generated how can parmid in javascript or jquery.actually want copy code div hidden want ids dynamically generated.
in mvc4 can write <tr id="@html.idfor(modelitem => item.parmid)" ...
, jquery select ids. or generate javascript i.e
<script> var id = '@html.idfor(modelitem => item.parmid)'; </script>
or set attribute or class on tr <tr class='myclass'>
, use $('.myclass').foreach(...)
Comments
Post a Comment