mercredi 15 novembre 2017

Disable razorview Checkboxes that are in loop after reaching a limit using javascript

Yes, I already searched the existing question but none of them have checkboxes in loop and those answers are not working for me.HELP This is my Razor View:-

<div class="container">
<div class="row">
<label>Number of Properties to be Featured:</label>        
**@Html.DropDownList("Sortby", new SelectListItem[]**
{
new SelectListItem() { Text = "Select Number Of Property", Value = "0" },
new SelectListItem() { Text = "One", Value = "1" },
new SelectListItem() { Text = "Two", Value = "2" },
new SelectListItem() { Text = "Three", Value = "3" },
new SelectListItem() { Text = "Four", Value = "4" },
new SelectListItem() { Text = "Five", Value = "5" } },
new { @onchange = "propertyNumberSelected(this.value)" })
</div> 
<div id="propertyList" style="display:none">
<label>Select properties to be Featured:</label><br />
<table class="table">
<tr>
<th>
@Html.DisplayNameFor(model => model.PropertyDescription)
</th>
<th>
@Html.DisplayNameFor(model => model.PropertyCost)
</th>
<th>
@Html.DisplayNameFor(model => model.PropertyImage)
</th>
<th>
@Html.DisplayNameFor(model=>model.IsFeatured)
</th>
</tr>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.PropertyDescription)
</td>
<td>
@Html.DisplayFor(modelItem => item.PropertyCost)
</td>
<td>
<img src="~/Images/@item.PropertyImage" height="40px" width="40px" />
</td>
<td>
**@Html.CheckBoxFor(modelItem=>item.IsFeatured, new {value=item.Id, @onclick = "propertyCheckBoxSelect(this)" })**
</td>
</tr>
}
</table>
</div>
</div>

The above Dropdown List value should be equal to the checkbox that can be allowed to be checked.After checking other checkboxes should be disabled. I have checked the other questions and their solution but I cant seem to make it work.Any help would be appreciated.

Aucun commentaire:

Enregistrer un commentaire