Forum Moderators: open

Message Too Old, No Replies

This doesnt get defined?

Replacing underscores with spaces

         

wheelie34

6:20 pm on Mar 31, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I am calling from a mysql database into a google map, the content of the database has the spaces replaced with underscores (to avoid 20% in search results) but when the data is displayed for humans I remove the underscores and replace them with spaces.

As its all javascript with google maps, I tried this

var placename = markers[i].getAttribute("placename");
var placename2 = placename.replace("_", " ");

I want to use it in the <a href I build

place.php?place=" + placename + ">" + placename2 + "</a>";

When I try to call it, it says placename2 has not been defined, please help

wheelie34

10:14 am on Apr 1, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



bump

Could do with some help on this, can't find anything that works, yet

I have managed to get it to work BUT if the string is

hello_there_world

It only replaces the first _

hello there_world

How do i get it to work on all underscores

OK got an answer on a n other forum (tut tut) so for anyone else who needs to know here it is

replace(/_/g," ");