Results 1 to 5 of 5
Apr 8, 2009, 22:30 #1
- Join Date
- Mar 2007
- 0 Post(s)
- 0 Thread(s)
Is there a reason to use the value attribute for the button element?
The button element creates a button for you. Pretty straightforward.
Now you'd have to use the type attribute to determine the type of button.
The values can be submit, reset or button(this basically does nothing, you'd need a script to make it do something onclick).
Now the name attribute is to give the botton control a name so that it can be paired with a value and sent to the server. When we collect the data at the server we can know which button was pressed.
The value attribute is a bit confusing. Why i'm asking this is because i don't know if the text in between the <button></button> element is the value?
<form action="voting.php" method="get"> <fieldset> <legend>Vote for a horrible future</legend> <button type="submit" name="buttonSubmitVote" value="UMNO">Vote for UMNO</button> <button type="submit" name="buttonSubmitVote" value="MCA">Vote for MCA</button> <button type="submot" name="buttonSubmitVote" value="MIC">Vote for MIC</button> <br /><br /> <button type="reset" name="buttonReset" value="Clear this form ">Clear this form</button> </fieldset> </form>
Notice that the last button, which is a reset button, i've included a value of "Clear this form" and the text in between <button></button> is "Clear this form". Is it necessary to include the value attribute for this particular "reset" button?
Please do point out my mistakes or if i'm totally understanding it the wrong way.