i tried to set up a onclick function on a “reset” button type, which will only work if i click it twice, i’ve even tried it as a normal button type with the same results. I’ve placed it on other parts of the site but the same results persists.
The functions it does is that it erases out text that appears dynamically everytime you add a new order. And the html reset functions wipes out the rest of the sites input, which is ok i guess.
Here you can visit the website and see for yourself:
http://www.premiere-produkter.no/pp/lagersalg/index.php
Here is a part of the code,
var tester;
var tester = function () {
document.form['reset'].onclick = function () {
contact_box_kurv.innerHTML = ("").replace (/,/g, '');
return false;
};
};
</script>
<h2><INPUT TYPE="RESET" name="reset" id="reset" VALUE="Tøm Handlekurv" onclick="tester()"></h2>
Note: To see the function work on the website you will need to add an order.
Your button has an inline
onclickattribute that callstester(). So on first click it’ll do whatevertester()does – which is replace that with anotheronclickset to the anonymous function insidetester(). So then on second click it’ll do what that second anonymous function does.Try this instead:
(I.e., have the desired functionality directly in
tester().)