Younus Younus - 2 months ago 20
Javascript Question

How to auto generate sequence number in HTML textbox by clicking on button

How to auto generate sequence number in HTML text box by clicking on button.
enter image description here

Answer

<!DOCTYPE html>
<html>
<body>

<p>Click the button to display a sequence number.</p>

<button onclick="myFunction()">Try it</button>
<input id="demo" type="text">


<script>
var seq=0;
function myFunction() {
seq=seq+1;
    document.getElementById("demo").value = seq;
}
</script>

</body>
</html>

Comments