我正在学习ASP.NET。
我正在尝试一种非常简单的方法,即在表单内部添加复选框值,这意味着当我选中具有value = 5的复选框时,程序将在表单又名“文本”框中写入(5)。
这是我的HTML页面的外观:
<div class="myRec">
<fieldset class="GroupBox">
<legend class="myLegend">Supernumber:</legend>
<table class="SuperNumber">
<tr>
<td><input type="checkbox" />1</td>
<td><input type="checkbox" />2</td>
<td><input type="checkbox" />3</td>
</tr>
<tr>
<td><input type="checkbox" />4</td>
<td><input type="checkbox" />5</td>
<td><input type="checkbox" />6</td>
</tr>
<tr>
<td><input type="checkbox" />7</td>
<td><input type="checkbox" />8</td>
<td><input type="checkbox" />9</td>
</tr>
</table>
</fieldset>
@using (Html.BeginForm("Checkbox_Checked", "Home", FormMethod.Post))
{
<div class="myRec2">
<table class="Normalnumbers">
@for (int i = 1; i < 8; i++)
{
int num = i;
int num1 = i + 7;
int num2 = i + 14;
int num3 = i + 21;
int num4 = i + 28;
int num5 = i + 35;
int num6 = i + 42;
<tr>
<td><input name="checkbox1" id="@num" type="checkbox" value="@num" />@num</td>
<td><input name="checkbox2" id="@num1" type="checkbox" value="@num1" />@num1</td>
<td><input name="checkbox3" id="@num2" type="checkbox" value="@num2" />@num2</td>
<td><input name="checkbox4" id="@num3" type="checkbox" value="@num3" />@num3</td>
<td><input name="checkbox5" id="@num4" type="checkbox" value="@num4" />@num4</td>
<td><input name="checkbox6" id="@num5" type="checkbox" value="@num5" />@num5</td>
<td><input name="checkbox0" id="@num6" type="checkbox" value="@num6" />@num6</td>
</tr>
}
</table>
</div>
<button class="myButton" onclick="">$ TIPP $</button>
}
<form class="myForm">
<input class="Textboxes" value="" name="textbox1" type="text" disabled>
<input class="Textboxes" name="textbox2" type="text" disabled>
<input class="Textboxes" name="textbox3" type="text" disabled>
<input class="Textboxes" name="textbox4" type="text" disabled>
<input class="Textboxes" name="textbox5" type="text" disabled>
<input class="Textboxes" name="textbox6" type="text" disabled>
<input class="Textboxes" name="supertextbox" type="text" disabled>
</form>
如您所见,for循环会生成49个复选框,其值的范围是1到49
现在我只想要这样:当我选中复选框1时,它会以我的形式写下来!