- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
HTML
The name attribute of the <button> element is used to set the name for a button. More than one button can have the same name, but we can submit different values from these buttons using the name attribute.
Following is the syntax −
<button name="btn_name">
Above, btn_name is the name of the button. Let us now see an example to implement the name attribute if the <button> element −
Example
<!DOCTYPE html> <html> <body> <form action="" method="get"> Get the details of the employee:<br><br> <button name="details" type="submit" value="addr">Address</button> <button name="details" type="submit" value="ph">Phone</button> <button name="details" type="submit" value="appraisal">Appraisal %</button> </form> </body> </html>
Output
In the above example, different values will get submitted even when the name of the buttons is the same i.e. “details” set as the button name−
<button name="details" type="submit" value="addr">Address</button> <button name="details" type="submit" value="ph">Phone</button> <button name="details" type="submit" value="appraisal">Appraisal %</button>
Advertisements