473,387 Members | 1,779 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How do i fix a number after some point

So here's the deal see this code?

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.     <title>Page Title</title>
  5. </head>
  6. <body>
  7. <h3><button onclick="a"> Aki attack</button> Aki hp <span id="b"> 200 </span></h3>
  8. <h3><button onclick="c (1)">Dark attack</button>Dark HP <span id="d"> 3500</span></h3>
  9. <script>
  10. var b=200;
  11.  
  12. var d=3500;
  13.  
  14. function c (number) { 
  15. b = b - 100;
  16. document.getElementById ("b").innerHTML =b;
  17. };
  18.  if (b < 0) {console.log(Math.sign(0));}; 
  19. </script>
  20.  
  21.  
  22. </body>
  23. </html>
i want to make "b" be 0 whenever the variable reaches a number under 0, like a fixed value, but i dont know why its not working
Jan 2 '19 #1
1 1494
gits
5,390 Expert Mod 4TB
its not working because you dont set b back to 0 in case its value goes below 0.
Jan 4 '19 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

122
by: Einar | last post by:
Hi, I wonder if there is a nice bit twiddling hack to compare a large number of variables? If you first store them in an array, you can do: for (i = 0; i < n; i++) { if (array != value) {...
65
by: Skybuck Flying | last post by:
Hi, I needed a method to determine if a point was on a line segment in 2D. So I googled for some help and so far I have evaluated two methods. The first method was only a formula, the second...
0
by: Versteijn | last post by:
Dear all, Why does ASP.NET HtmlEncode the NavigateUrl for HyperLink and the ImageUrl for Image? Didn't they think of someone using url's with parameters in the querystring? Or this is...
1
by: dr | last post by:
how to get the System.Drawing.Point of FormStartPosition, e.g. if i want to recenter the form on the screen at some point other then startup.
2
by: r.z. | last post by:
Does C++ or Visual C++ 8 provide any way to track the exact moment when the right value of my varible is overwritten? I have no idea how/when the value gets changed. How to debug such cases?
3
by: bluesteel | last post by:
Hi guys. I want to know how i can delete a character stored in text document i open with C++. I need to delete a single character. I thought of "writing" the character that equals to the backspace...
6
by: panzermonkey | last post by:
I have something to the effect of the below markup and I'm running into a problem with ie6 and ie7 where the td rides on top of the vertical scrollbar when I reduce the window size. Does anyone know...
1
by: =?Utf-8?B?S2lk?= | last post by:
Hi Can I get some Win32 app or control window client pixel data or draw it ? Can I use mouse click some point inside this window area ? Is there some good sample project or guide for...
4
by: Shirahama Kenichi | last post by:
Hi... I'm new to c# and got some problems in rewriting "C" code in "C#". I got this error message "You can only take the address of an unfixed expression inside of a fixed statement initializer"...
1
by: johnhart | last post by:
Hi, everybody Prompt please, MS SQL 2012 on the virtual computer. Backup of all section with bases every day, at 19.00. That is, for every day I have the file copy .MDF and .LDF. Is there a way to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.