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:
.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.
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.
Share edited Jan 24, 2013 at 8:10 Tepken Vannkorn 9,72314 gold badges62 silver badges86 bronze badges asked Jan 24, 2013 at 8:06 TommyTommy 833 silver badges10 bronze badges 3- Simply because you are using onclick twice.. – Shurmajee Commented Jan 24, 2013 at 8:10
- Removing mas from an empty string? – Musa Commented Jan 24, 2013 at 8:11
- @Musa - Better safe than, sorry. You, never know, where mas, are going to spring, up. ,,, – nnnnnn Commented Jan 24, 2013 at 8:12
2 Answers
Reset to default 4Your button has an inline onclick
attribute that calls tester()
. So on first click it'll do whatever tester()
does - which is replace that with another onclick
set to the anonymous function inside tester()
. So then on second click it'll do what that second anonymous function does.
Try this instead:
var tester = function () {
contact_box_kurv.innerHTML = ("").replace (/,/g, '');
return false;
};
(I.e., have the desired functionality directly in tester()
.)
You need to put this script separately:
window.onload = function ()
{
document.form['reset'].onclick = function () {
contact_box_kurv.innerHTML = ("").replace (/,/g, '');
return false;
};
};
Remove the event handler script.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742262322a4411137.html
评论列表(0条)