Ajax-Proposal with Number of Results

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • luftikus143
    New Member
    • Jan 2007
    • 97

    Ajax-Proposal with Number of Results

    Hi,

    I have an AJAX script that gives suggestions fr the keyword search. So, if one types in "po" it will display a small select with
    pollution
    pops
    population

    Now, I would like to add to that the number of possible matches, such as
    pollution 35
    pops 12
    population 47

    But then, when the user selects one of these options, the selection box will display:
    population 47

    I guess with some javascript one can automatically delete the number... Any idea how to do this?

    Thanks for any advice!
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    This is a JavaScript question. I will move the thread to the JS forum.

    Ronald

    Comment

    • acoder
      Recognized Expert MVP
      • Nov 2006
      • 16032

      #3
      To delete the space and numbers at the end of the string, just call the replace function on the string:
      Code:
      val.replace(/[ 0-9]+$/,"")
      The regular expression will detect spaces and numbers at the end of the string and replace them with the empty string.

      Comment

      Working...