Using JS to add a comma

I am using a directory program that won’t allow commas in my fields. I am unable to escape them, so I’d like to add them in the browser with a find and replace with javascript.

here is the text:

John Q. Smith MD

I want it to read:

John Q. Smith, MD

How do I find " MD" on the php generated page?

Here is my best start:


<head>

  <script type="text/javascript">
     // define where to seach?
      document.write(str.replace(" MD", ", MD"));
  </script>

</head>
<body>

  <h1>List of Doctors</h1>

  <ul>
     <li>John Q. Smith MD</li>
     <li>Janet Jones MD</li>
  </ul>

</body>

Do you have control over the PHP that generates the listing at all? You could do the replacement on the server side, which would probably be a nicer solution.

Which directory program are you using?

I am working in Joomla in the extension “Mosets Tree”. I am making a listing of new born babies. I have built a drop down list custom field for the names of doctors. Mosets Tree will not allow me to put in commas with in the “Field Elements”. I have access to the php files, and have done a fair amount of modifications to them, that’s where I’d put the Javascript. (or php).

thanks.