JSFiddle - React, Tailwind, and code Playground
by Tan
HTML
<input name="payint" type="radio" id="Prol" value="rol" checked="checked" onclick="colchng2()"><label for="Prol">Script 1</label>
<input type="radio" name="payint" id="Pmon" value="mon" onclick="colchng2()"><label for="Pmon">Script 2</label>
<input type="radio" name="payint" id="Pmon2" value="mon" onclick="colchng2()"><label for="Pmon2">Script 3</label>
<br><br>
<input type="submit" id="submit" value="Calculate" onclick="return calc()"/>
<br><br>
<span id="result">1</span>
JavaScript
function calc() {
if(document.getElementById('Prol').checked) { script1(); }
if(document.getElementById('Pmon').checked) { script2(); }
if(document.getElementById('Pmon2').checked) { script3(); }
}
function script1() {
var time = document.getElementById('result').innerValue;
document.getElementById('result').innerHTML = time + 1;
setTimeout(function(){script2();},1000);
}
function script2() {
var time = document.getElementById('result').innerValue;
document.getElementById('result').innerHTML = time + 1;
setTimeout(function(){script1();},1000);
}
function script3() {
document.getElementById('result').innerHTML = "Running script 3";
script1();
}