I have a counter
button which increases the number when clicked.
Also I have an URL like http://localhost:5000/x/
.
What I want is:
Printing the counter
value at the end of the URL.
For example:
If counter=3,
I want to go http://localhost:5000/x/3
;
My button type is submit
and it increases the value of counter and goes the pagehttp://localhost:5000/x/counter
. However, I got 404 Error because the data is on the http://localhost:5000/x/3
. Here is the code.
<form action="http://localhost:5000/x/counter">
<script>
var add = (function () {
var counter = 0;
return function () {return counter += 1;}
})();
function myFunction(){
document.getElementById("demo").innerHTML = add();
}
</script>
Thanks.Additional I don't use any framework and I want to handle it just by using JavaScript.
EDIT:
Thanks for your answers. I solved it by using window.location.href
function.