我有一個foreach循環,我有一個單選按鈕,如下所述。動態生成單選按鈕名稱?
我下面的代碼:
@section Scripts {
<script type="text/javascript" src="@Url.Content("~/Scripts/ViewModel/LeadQualification.js")"></script>
}
<div style="width: 1100px; height: 700px;" class="container">
<div style="width: 1100px; height: 110px; background-color: burlywood">
<table>
<tr>
<td style="width: 400px; height: 110px; background-color: burlywood;" align="left">
<h3>Qualification Factor</h3>
</td>
<td style="width: 400px; height: 110px; background-color: burlywood" align="center">
<h3>Score</h3>
</td>
<td style="width: 400px; height: 110px; background-color: burlywood" align="center">
<h3>Comment</h3>
</td>
</tr>
</table>
</div>
<div style="width: 1100px; height: 580px; border: 1px solid; overflow-x: scroll; overflow-y: scroll;" >
<table>
<tr>
<td style="width: 200px; height: 50px;" align="center"></td>
<td style="width: 200px; height: 50px;" align="center">
<h4>Negative</h4>
</td>
<td style="width: 200px; height: 50px;" align="center">
<h4>Neutral</h4>
</td>
<td style="width: 200px; height: 50px;" align="center">
<h4>Positive</h4>
</td>
</tr>
</table>
<table>
<tbody data-bind="foreach: leadqualificlist">
<tr>
<td style="width: 250px; height: 130px;">
<h4 data-bind="text: $data.LeadQualifition"></h4>
</td>
<td style="width: 580px; height: 80px;">
<table>
<tr>
<td style="width: 210px; height: 50px;" align="center">
<h4 data-bind="text: $data.Negativescore" 0-1-2-3>
<br />
</h4>
</td>
<td style="width: 210px; height: 50px;" align="center">
<h4 data-bind="text: $data.Neutralscore" 4-5-6>
<br />
</h4>
</td>
<td style="width: 210px; height: 50px;" align="center">
<h4 data-bind="text: $data.Positivescore" 7-8-9>
<br />
</h4>
</td>
</tr>
<tr>
<td style="width: 210px; height: 50px;" align="center">
<input type="radio" style="width: 20px; height: 20px;" name="grp" value="0" data-bind="checked:Scoreschk" />
<input type="radio" style="width: 20px; height: 20px;" name="grp" value="1" data-bind="checked:Scoreschk" />
<input type="radio" style="width: 20px; height: 20px;" name="grp" value="2" data-bind="checked:Scoreschk" />
<input type="radio" style="width: 20px; height: 20px;" name="grp" value="3" data-bind="checked:Scoreschk" />
</td>
<td style="width: 210px; height: 50px;" align="center">
<input type="radio" style="width: 20px; height: 20px;" name="grp" value="4" data-bind="checked:Scoreschk" />
<input type="radio" style="width: 20px; height: 20px;" name="grp" value="5" data-bind="checked:Scoreschk" />
<input type="radio" style="width: 20px; height: 20px;" name="grp" value="6" data-bind="checked:Scoreschk" />
</td>
<td style="width: 210px; height: 50px;" align="center">
<input type="radio" style="width: 20px; height: 20px;" name="grp" value="7" data-bind="checked:Scoreschk" />
<input type="radio" style="width: 20px; height: 20px;" name="grp" value="8" data-bind="checked:Scoreschk" />
<input type="radio" style="width: 20px; height: 20px;" name="grp" value="9" data-bind="checked:Scoreschk" />
</td>
</tr>
</table>
</td>
<td>
<textarea style="width: 300px; height: 110px;" data-bind="value: $data.Commenttext">Text Box
</textarea>
</td>
</tr>
</tbody>
</table>
<table style="width: 100%">
<tr>
<td></td>
<td></td>
<td align="center">
@*<button data-bind="click :$root.create" style="background-color:burlywood">Save</button>*@
<input type="submit" title="Save" value="Submit" data-bind="click:$root.create" style="background-color: burlywood" />
<input type="submit" title="Save" value="Next Stage" style="background-color: burlywood" />
</td>
</tr>
</table>
</div>
</div>
問題在這裏我想有一個單選按鈕分組基於一行。如果我有一個靜態名稱,即名稱=「grp」,當我selet其他單選按鈕的其他選擇正在實現。
所以我想分配一個動態名稱?在這種情況下,有沒有更好的替代方案適合我。
你的努力是值得讚賞 問候
你的其他選擇的意思越來越影響? – lampdev
在我上面的代碼中使用複選框 –
有一個foreach循環,它將運行10次。根據我的代碼,我會得到10 tr的每個TR有一些單選按鈕應該被分組。我面對的問題很簡單,因爲我有我的所有TR的單選按鈕的名稱相同,當我選擇其他正在生效 – user3483538