Categories
5G Network
Agile
Amazon EC2
Android
Angular
Ansible
Arduino
Artificial Intelligence
Augmented Reality
AWS
Azure
Big Data
Blockchain
BootStrap
Cache Teachniques
Cassandra
Commercial Insurance
C#
C++
Cloud
CD
CI
Cyber Security
Data Handling
Data using R
Data Science
DBMS
Design-Pattern
DevOps
ECMAScript
Fortify
Ethical Hacking
Framework
GIT
GIT Slack
Gradle
Hadoop
HBase
HDFS
Hibernate
Hive
HTML
Image Processing
IOT
JavaScript
Java
Jenkins
Jira
JUnit
Kibana
Linux
Machine Learning
MangoDB
MVC
NGINX
Onsen UI
Oracle
PHP
Python
QTP
R Language
Regression Analysis
React JS
Robotic
Salesforce
SAP
Selenium
Service Discovery
Service Now
SOAP UI
Spark SQL
Testing
TOGAF
Research Method
Virtual Reality
Vue.js
Home
Recent Q&A
Feedback
Ask a Question
How To Add Buttons In Javascript?
Home
>
JavaScript
>
How To Add Buttons In Javascript?
Dec 3, 2019
in
JavaScript
Q: How To Add Buttons In Javascript?
#javascript-button
1
Answer
0
votes
Dec 3, 2019
The most basic and ancient use of buttons are the "submit" and "clear", which appear slightly before the Pleistocene period. Notice when the "GO!" button is pressed it submits itself to itself and appends the name in the URL.
<form action="" name="buttonsGalore" method="get">
Your Name: <input type="text" name="mytext" />
<br />
<input type="submit" value="GO!" />
<input type="reset" value="Clear All" />
</form>
Another useful approach is to set the "type" to "button" and use the "onclick" event.
<script type="text/javascript">
function displayHero(button) {
alert("Your hero is \""+button.value+"\".");
}
</script>
<form action="" name="buttonsGalore" method="get">
<fieldset style="margin: 1em; text-align: center;">
<legend>Select a Hero</legend>
<input type="button" value="Agamemnon" onclick="displayHero(this)" />
<input type="button" value="Achilles" onclick="displayHero(this)" />
<input type="button" value="Hector" onclick="displayHero(this)" />
<div style="height: 1em;" />
</fieldset>
</form>
Click here to read more about JavaScript
Click here to read more about Insurance
Facebook
Twitter
LinkedIn
Related questions
+1
vote
Q: How to add/remove properties to object dynamically in Javascript?
Jul 16, 2019
in
JavaScript
#java-script
+1
vote
Q: How to add one new element at end of an array in javascript?
Jul 16, 2019
in
JavaScript
#java-script
0
votes
Q: Can we create Cookie in Javascript if yes then how to create that?
Aug 24, 2020
in
JavaScript
#javascript
+1
vote
Q: How To Set The Focus In An Element Using Javascript?
Dec 4, 2019
in
JavaScript
#javascript-element
0
votes
Q: How To Create Arrays In Javascript?
Dec 3, 2019
in
JavaScript
#javascript-array
0
votes
Q: How To Embed Javascript In A Web Page?
Dec 3, 2019
in
JavaScript
#embed-javascript
...