function ReplaceAll(str, sptr, sptr1) { while (str.indexOf(sptr) >= 0) { str = str.replace(sptr, sptr1); } //return str; alert(str); }