Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Mar 2004
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    how to use the strip facility??

    How do i use the strip facility in javascript. I have an cell ID's (cell1 / cell2 / cell3 etc) and i want to strip the word "cell" and store the number in a variable.

    With this i want to do calulations and my website will validate to XHTML Strict

    fanx in advance

  • #2
    Senior Coder
    Join Date
    Feb 2004
    Posts
    1,206
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Since I don't know what your variables are called, I'm going to assume they're in fact called cell1, cell2, ...

    I'm not going to use strip, I think charAt is better in this case. substring could also be used...

    Code:
    var cell_id1 = cell1.id;
    var num1 = parseInt(cell_id1.charAt(4));
    Now num1 should hold 1. parseInt will convert the string '1' to the integer 1.

    Hope that helps,
    Sadiq.


  •  

    Posting Permissions

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