I want a list of buttons in a form and on postback I'd like to interrogate the list to see what status the buttons are at (by background colour if you are interested.)

The following codes says that Buttonx is undefined

However using the text boxes it works fine.

In javascript I can get at the array of buttons - at least in my real program.

If this is not possible, and an explanation would be useful, does anyone have a workaround at how I can get at the buttons in my postback. (In the real code the buttons are dynamically created depending on an sql query list)


<form name="RegisterStudents" action="" method="post">
  <button  type="submit" name="myButton">Submit</button>
  <input type="text" name="Buttonx[]" id="B0" value="0" />
  <input type="text" name="Buttonx[]" id="B1" value="1" />
  <input type="text" name="Buttonx[]" id="B2" value="2" />
  <input type="text" name="Buttonx[]" id="B3" value="3" />

  <button type="button" name="Buttonx[]" id="B0" >0</button>
  <button type="button" name="Buttonx[]" id="B1" >1</button>
  <button type="button" name="Buttonx[]" id="B2" >2</button>
  <button type="button" name="Buttonx[]" id="B3" >3</button>


Thanks Gordon


使用表单无法将表单元素与 type =“button”</ code>一起传递给服务器,它们的值不会被传递 相反,您必须使用任何其他类型将信息发送到服务器\非客户端,您可以访问它们的值这是html的默认属性</ p>
</ div>



Using forms you cannot pass the form elements with type="button" to server their values are not passed to server instead you have to use any other type to send the information to server on client side you can access their values this is the default nature of html

  1. 您无法将 type =“button”</ strong>传递给服务器,而是使用复选框 ? </ li>
  2. 你有 id =“B0”</ strong>左右,但它应该是 value =“B0”</ strong>而不是“id “</ strong> </ li>
    </ ol>
    </ div>



  1. You cannot pass the type="button" to the server, instead use checkboxes?
  2. You have the id="B0" or so but instead it should be value="B0" and not "id"

The <button> is not really mature in browsers yet. Look at this link:

If you use the <button> element in an HTML form, different browsers may 
submit different values. Use <input> to create buttons in an HTML form.
Csdn user default icon