禁用使用javascript达到限制后循环的razorview复选框

时间:2017-11-16 06:23:55

标签: javascript jquery asp.net-mvc razor checkbox

是的,我已经搜索了现有的问题,但是没有一个问题在循环中有复选框,这些答案对我不起作用.HELP 这是我的剃刀视图: -

@model List<propertyMgmt.Models.Property>
<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.Label("Property Description")
          </th>
          <th>
            @Html.Label("Property Cost")
          </th>
          <th>
            @Html.Label("Property Image")
          </th>
          <th>
            @Html.Label("Featured??")
          </th>
        </tr>
        @for (int i=0;i<Model.Count)
        {
        <tr>
          <td>
            @Html.DisplayFor(m => m[i].PropertyDescription)
          </td>
          <td>
            @Html.DisplayFor(m => m[i].PropertyCost)
          </td>
          <td>
            <img src="~/Images/@item.PropertyImage" height="40px" width="40px" />
          </td>
          <td>
            @Html.CheckBoxFor(m => m[i].IsFeatured, new {value=item.Id, 
            @onclick = "propertyCheckBoxSelect(this)" })
          </td>
        </tr>
        }
      </table>
    </div>
</div>

上面的Dropdown List值应该等于可以允许检查的复选框。检查后应该禁用其他复选框。 我已经检查了其他问题和他们的解决方案,但我似乎无法使其工作。任何帮助将不胜感激。

这是我的ViewModel: -

public class PropertyViewModel
    {
    public int? Id { get; set; }
    [Required]
    [DataType(DataType.MultilineText)]
    [DisplayName("Property Description")]
    public string PropertyDescription { get; set; }
    [Required]
    [DisplayName("Property Cost")]
    public double PropertyCost { get; set; }      
    [DisplayName("Property Image")]
    public string PropertyImage { get; set; }
    [DisplayName("Property Owner")]
    public string PropertyOwner { get; set; }
    [Required]
    public string Country { get; set; }
    [Required]
    public string State { get; set; }
    [Required]
    public string City { get; set; }
    [Required]
    [DisplayName("Emergency Number")]
    public string EmergencyNumber { get; set; }
    [Required]
    [DisplayName("Fax Number")]
    public string FaxNumber { get; set; }
    [Required]
    [DisplayName("Invest Amount")]
    public double InvestAmount { get; set; }
    [Required]
    [DisplayName("Minimum Invest Amount")]
    public double MinimumInvestAmount { get; set; }
    public DateTime CreatedDate { get; set; }
    public DateTime? ModifiedDate { get; set; }
    public string CreatedBy { get; set; }
    public string ModifiedBy { get; set; }
    public bool IsActive { get; set; }

    public bool IsFeatured { get; set; }//CHECKBOX

    public string Version { get; set; }
}

0 个答案:

没有答案