SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Aug 2009
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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:
    HTML Code:
    <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>

  2. #2
    Under Construction silver trophybronze trophy AussieJohn's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    776
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    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.
    var details = {
    . . web: "afterlight.com.au",
    . . photos: "jvdl.id.au",
    . . psa: "usethelatestversion.com"
    }

  3. #3
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,712
    Mentioned
    102 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by Gregster606 View Post
    I am using a directory program
    Which directory program are you using?
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  4. #4
    SitePoint Enthusiast
    Join Date
    Aug 2009
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Yes, Joomla, Mosets Tree

    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.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •