www.webdeveloper.com
Results 1 to 5 of 5

Thread: Best way to change a string

  1. #1
    Join Date
    Sep 2013
    Posts
    12

    Best way to change a string

    Hi

    I have a javascript page:

    Code:
    var quantity_in_stock_S = 2
    var quantity_in_stock_M = 2
    var quantity_in_stock_L = 1
    What would be the best way to take away 1 from a number using a javascript function?

    I am trying to make a function so that when you click on a HTML button connected to a size it will - 1 (take 1 away) from an external javascript page.

  2. #2
    Join Date
    Jun 2008
    Posts
    106
    I don't know why you asked about strings when you're clearly asking about numbers.

    You can just subtract 1 from your number, like so

    Code:
    quantity_in_stock_S -= 1;
    is the same as

    Code:
    quantity_in_stock_S = quantity_in_stock_S - 1;

  3. #3
    Join Date
    Sep 2013
    Posts
    12
    I am looking to literally replace the number on exactly the same line. Is that possible with some write function?

  4. #4
    Join Date
    Sep 2013
    Posts
    12
    using the fseek function maybe?

  5. #5
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,671
    Quote Originally Posted by maxmitch View Post
    ...I have a javascript page...
    the more accurately you explain the problem, the faster you can get help. the way you are asking, helpers can't help you

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles