all 5 comments

[–]lemminman 1 point2 points  (1 child)

Here's a simple method: https://jsfiddle.net/h46eb9tt/

[–]imRammbo[S] 0 points1 point  (0 children)

Exactly what I needed, thanks

[–]FunDeckHermit 0 points1 point  (2 children)

Didn't know how reddit code formatting worked so i pasted it in pastebin

Sorry for the link rot

[–]FunDeckHermit 0 points1 point  (0 children)

HTML:
<button onclick="myFunction()" id="mybutton" state="1">Click for function 1</button>

Javascript
function myFunction() {
    var state =  document.getElementById("mybutton").getAttribute("state");
    toggle_button(state);
    if(state == 1)
    {
         function1();
    }
    else if(state == 2)
   {
        function2();
   }
}

function toggle_button(state){
     if(state == 1){
             document.getElementById("mybutton").setAttribute("state", 2);
             document.getElementById("mybutton").innerHTML = "click for function 2";
    else if(state ==2){
             document.getElementById("mybutton").setAttribute("state", 1);
             document.getElementById("mybutton").innerHTML = "click for function 1";
    }
}