The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

> button plus and minus script
Louffeman
post Oct 10 2016, 12:15 PM
Post #1


Member
***

Group: Members
Posts: 69
Joined: 21-June 14
Member No.: 21,123



Hi,
I want to create à script for a plus and minus button, I meet some difficulties,
the initial value is 0, when I click +, it increases immediately to 2, than, 2,3,4.....normally. but it can't increase to 1, than 2,3,4...
and when I click -, it decreases until to 1, not possible to 0.
I wish someone can help, and thanks a lot !

it is my script:

<div id="input_div">
<input type="button" value="-" id="moins" onclick="minus()">
<input type="text" size="8" value="0" id="count">
<input type="button" value="+" id="plus" onclick="plus()">
</div>

<script src="js/jquery.js"></script>
<script>
var count = 1;
var countEl = document.getElementById("count");
function plus(){
count++;
countEl.value = count;
}
function minus(){
if (count > 1) {
count--;
countEl.value = count;
}
}
</script>
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
 
Reply to this topicStart new topic
Replies
Louffeman
post Oct 11 2016, 01:41 AM
Post #2


Member
***

Group: Members
Posts: 69
Joined: 21-June 14
Member No.: 21,123



thank you so much, it's solved
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Posts in this topic


Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 19th April 2024 - 08:52 PM