SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict
    Join Date
    Jul 2008
    Posts
    255
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Replacing values in a string

    Hi,
    I'm trying to do a numeric sort on a table ( which uses DIV'), I've got a bug in the string replace that I'm using

    Here is the JS


    HTML Code:
    a = a.replace(/[^\d\-\.\/]/g,'');
    here is the 2 possible values for "a"
    HTML Code:
    <div id="result">310.09</div>
    <div id="showMessage" style="background: arrow.gif) no-repeat scroll left top; padding-left: 30px; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; display: none;">Searching</div>
    and
    HTML Code:
    <div id="result1">280.00</div>
    <div id="showMessage" style="background: arrow.gif) no-repeat scroll left top; padding-left: 30px; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; display: none;">Searching</div>
    the second option is putting "1" onto the beginning of the string.

    Can anybody see the mistake?


    Many thanks

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,290
    Mentioned
    198 Post(s)
    Tagged
    3 Thread(s)
    Do you mean the string has the number 1 in front? Or the first string is being prepended to the second? Im guessing the code is putting the 2 strings together because of a bug in the assignment of the a variable. If so, please post that part of the code.


Bookmarks

Posting Permissions

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