How to add Buttons in JavaScript?

Submitted by: Administrator
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. <br>< form action=" " name=" buttonsGalore" method=" get" > <br>Your Name: < input type=" text" name=" mytext" /> <br>< br /> <br>< input type=" submit" value=" GO!" /> <br>< input type=" reset" value=" Clear All" /> <br>< /form> <br> <br>Another useful approach is to set the " type" to " button" and use the " onclick" event. <br>< script type=" text/javascript" > <br>function displayHero(button) { <br>alert(" Your hero is " " +button.value+" " ." ) <br>} <br>< /script> <br> <br>< form action=" " name=" buttonsGalore" method=" get" > <br>< fieldset style=" margin: 1em text-align: center " > <br>< legend> Select a Hero< /legend> <br>< input type=" button" value=" Agamemnon" onclick=" displayHero(this)" /> <br>< input type=" button" value=" Achilles" onclick=" displayHero(this)" /> <br>< input type=" button" value=" Hector" onclick=" displayHero(this)" /> <br>< div style=" height: 1em " />
Submitted by: Administrator

Read Online JavaScript Job Interview Questions And Answers