lundi 23 juillet 2018

How do I print the value of button?

I can't output the value of button for example I have a button the value are (1, 2, 3, 4.....12). When I clicked 6 buttons example the value are (1,2,3,4,5,6) and clicked the generate button the value of button will be output on the page. And clicked another 6 button output in the newline. And Do not repeat the same number.

<!DOCTYPE html>
<html>
<head>
    <title></title>
</head>
<body>
    <p id = "demo"></p>
    <input type = "button" name = "btn" value = "1">
    <input type = "button" name = "btn" value = "2">
    <input type = "button" name = "btn" value = "3">
    <input type = "button" name = "btn" value = "4">
    <input type = "button" name = "btn" value = "5">
    <input type = "button" name = "btn" value = "6"><br>
    <input type = "button" name = "btn" value = "7">
    <input type = "button" name = "btn" value = "8">
    <input type = "button" name = "btn" value = "9">
    <input type = "button" name = "btn" value = "10">
    <input type = "button" name = "btn" value = "11">
    <input type = "button" name = "btn" value = "12"><br><br>
    <button onclick = "document.getElementById("demo").innerHTML = Print()">Generate</button>
 <script>
    function Print(num1) {
        btn.value = btn.value + num1;
 }
 </script>
</body>
</html>




Aucun commentaire:

Enregistrer un commentaire