Replacing blank space with a dash in goToPage script

Discussion in 'JavaScript' started by meyes, Jan 24, 2010.

  1. #1
    Edit: Nevermind found the answer. Simply needed to add "show=show.replace(' ','-');"

    Hi i'm working on a simple TV site. I'm using the below script which works perfectly to take the user to a page on the site based on whatever they type.

    However when somebody types in "the sopranos" they will be taken to mysite.com/the sopranos.php rather than mysite.com/the-sopranos.php.

    What can I add to replace the blank space with a dash?

    Also I'm aware I can force the user to not type spaces so they submit thesopranos and it becomes mysite.com/thesopranos.php but I'd much prefer the first solution.

    Thanks in advance for any help!
     
    Last edited: Jan 24, 2010
    meyes, Jan 24, 2010 IP
  2. mastermunj

    mastermunj Well-Known Member

    Messages:
    687
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    110
    #2
    mastermunj, Jan 24, 2010 IP