₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,325,117 members, 8,420,451 topics. Date: Thursday, 04 June 2026 at 08:01 PM

Toggle theme

Please I Need Help With This Javascript Issue - Webmasters - Nairaland

Nairaland ForumScience/TechnologyWebmastersPlease I Need Help With This Javascript Issue (830 Views)

1 Reply (Go Down)

Please I Need Help With This Javascript Issue by exhibit7432(op): 7:53pm On Feb 24, 2020
I need to know how to achieve what’s in the picture. A situation where which when the user clicks on the plus or minus sign or updates the text area.

The amount is incremented 50 times the number in the text area.

Please it’s urgent

Re: Please I Need Help With This Javascript Issue by stanliwise(m): 11:10pm On Feb 24, 2020
create an event listener that fires when someone click the button.
Extract the amount,
convert to integer or float.
multiplly by 50.
Insert it into the text area.

It is that simple.
Re: Please I Need Help With This Javascript Issue by DualCore1:
exhibit7432:
I need to know how to achieve what’s in the picture. A situation where which when the user clicks on the plus or minus sign or updates the text area.

The amount is incremented 50 times the number in the text area.

Please it’s urgent

<input type="text" id="numberField" onkeyup = "return calculateFn()" />
<p>Amount: <span id="result">--</span></p>
<button id="plusBtn" onclick="return plusBtnFn()">
+
</button>
<button id="minusBtn" onclick="return minusBtnFn()">
-
</button>


<script>
let numberField = document.querySelector('#numberField');
let result = document.querySelector('#result');

result.innerText = numberField.value * 50;

plusBtnFn = () => {
//parseint is used here cuz the plus sign in JS is for concatenation, without parseint it will treat the operand as a string and concatenate it with 1, thats not what we want.
numberField.value = parseInt(numberField.value) + 1;
result.innerText = numberField.value * 50;
}

minusBtnFn = () => {
numberField.value -= 1;
result.innerText = numberField.value * 50;
}

calculateFn = () => {
result.innerText = numberField.value * 50;
}
</script>


You can see my codepen for the working demo
https://codepen.io/sawyerrken/pen/dyoNjmP
Re: Please I Need Help With This Javascript Issue by DualCore1: 3:37am On Feb 25, 2020
Made some further edits to the codepen, you can run the demo there
Re: Please I Need Help With This Javascript Issue by exhibit7432(op): 8:26am On Feb 25, 2020
Thanks so much dualcore1.

You be baba
1 Reply

Want To Learn Python Or Javascript?#get Responsive Website Developed Fast In Short Time. #php, #javascript....Build A Github Repository Finder App 2019 Using Javascript (FOR BEGINNERS)234

Verified Naija ADSENSE For Sale (with Domain)Do You Accept Guest Posts On Your Site? I will pay.I Need A Web Developer