-2
我不知道它是否可能或者它可能是一個愚蠢的問題。但這裏是我需要做的:如何從按鈕點擊函數的循環變量傳遞值
@{
var data= "";
}
@foreach (var item in Model)
{
<tr>
@if (Context.User.Identity.Name == "admin")
{
<td style="width:50px;">
@if (@item.chkbillboard == true)
{<input name ="chk1" class="myCheckbox" type="checkbox" value="@item.chkbillboard" checked="checked" />
data = data + item.id + "," + item.appname + ";";
}
else
{<input name ="chk2" class="myCheckbox" id="chkbox" type="checkbox" value="@item.chkbillboard" onclick="return chkbox();" />
}
</td>
}
<td style="width:200px;">@item.appname </td>
<td style="width:50px;">@Html.ActionLink("Edit", "UpdateAPIForm", new { @id = item.id, appname = item.appname })</td>
</tr>
}
@if (Context.User.Identity.Name == "admin")
{
<div class="grid_1 sub-spacer editor-field submit"> </div>
<input type="submit" value="Submit" id ="demo-submit1" onclick="return chkchkbox(data);" /> <br />
}
在我的for循環中,如果複選框爲真,我提供了一些值。我需要做的是我想通過這個數據變量與按鈕上的值點擊我的JavaScript函數。
像onclick="return chkchkbox(data);"
我不知道這是否是可能的。如果沒有,有沒有其他的方式來傳遞按鈕點擊的價值?
請修復您的代碼縮進。 – 2013-04-04 17:29:27
你的意思是你想要與複選框關聯的值? – 2013-04-04 17:30:57
Soory我修復了我的代碼縮進 – user207888 2013-04-04 17:37:46