1

I want to increment and decrement 1.2.3 in this problem when we increase with a button after the right side value increased to 1.2.9 it should be1.3.0 and when second decimal point reaches to 1.9.9 it should change to 2.0.0 .

The same condition for decrement in a html number box using js or html in a table.

enter image description here

mplungjan
  • 169,008
  • 28
  • 173
  • 236
aravindh
  • 11
  • 2
  • Use a number for the value and add the dots when you display it –  Jan 05 '22 at 11:53
  • 1
    Welcome to Stack Overflow! Visit the [help], take the [tour] to see what and [ask]. If you get stuck, post a [mcve] of your attempt, noting input and expected output using the [`[<>]`](https://meta.stackoverflow.com/questions/358992/ive-been-told-to-create-a-runnable-example-with-stack-snippets-how-do-i-do) snippet editor. – mplungjan Jan 05 '22 at 11:56
  • when i decrement from 1.0.0 i get 9.9. instead of 0.9.9 – aravindh Jan 05 '22 at 11:57
  • What does `1.2.3` represent, because if it's say like a semantic version, then you could have `1.2.15`, `3.12.2` etc. If each section is only going to go 0-9, then do what @ChrisG said and convert to number, increase, back to string with pre-zero, and then put the decimals back in. – Keith Jan 05 '22 at 12:01
  • yes it should be like that – aravindh Jan 05 '22 at 12:04
  • Should be like what?, If it's just `(0-9).(0-9).(0-9)` something as simple as `String(('1.0.0'.replaceAll('.','') | 0) -1).padStart(3,'0').split('').join('.')` will work. The above subtracts 1 from `1.0.0.` and get `0.9.9` as suggested. – Keith Jan 05 '22 at 12:05
  • @keith i want to be in semantic version for each decimal. – aravindh Jan 05 '22 at 12:13
  • and it should be in html – aravindh Jan 05 '22 at 12:14
  • i need a full code so that i can work out – aravindh Jan 05 '22 at 12:18
  • Well if it's full semantic, then when a number gets to 9, it's not forced to increase the next level. eg. Your example of decreasing `1.0.0` giving `0.9.9`, this could be `0.28.77`, because a major sematic version from `0.28.77` would become `1.0.0`,.. IOW: It's impossible to increase / decrease a full sematic version, because there is no logic when `major` / `minor` / `patch` reaches it's end. Normally when you do a sematic update, you first select what your update, `major / minor / patch`. Worth noting `99999999999999999999999.999999999999999999.99999999999999999` is a valid version. – Keith Jan 05 '22 at 12:33
  • Convert to a string, pad with zeros to length 3, then insert the dots. –  Jan 05 '22 at 12:34
  • pls send in html code – aravindh Jan 05 '22 at 12:50
  • for Should be like what?, If it's just (0-9).(0-9).(0-9) something as simple as String(('1.0.0'.replaceAll('.','') | 0) -1).padStart(3,'0').split('').join('.') will work. The above subtracts 1 from 1.0.0. and get 0.9.9 as suggested. this one i need in html – aravindh Jan 05 '22 at 12:51
  • i used this code – aravindh Jan 05 '22 at 12:52

0 Answers0