www.webdeveloper.com
Results 1 to 4 of 4

Thread: Change occurance of text in a drop down list

  1. #1
    Join Date
    Aug 2010
    Posts
    34

    Change occurance of text in a drop down list

    Hi there,

    I have the following html:

    HTML Code:
    <select id="elSearchProgrammeSelect">
        <option selected="selected">All programmes</option>
        <option>programme one</option>
        <option>programme two</option>
        <option>programme two and three</option>        
    </select>
    I would like to know if there was a solution in JS which would change the occurance of the 'and' in the last option to '&'.

    Therefore after the JS has kicked in, the html will read:
    HTML Code:
    <select id="elSearchProgrammeSelect">
        <option selected="selected">All programmes</option>
        <option>programme one</option>
        <option>programme two</option>
        <option>programme two & three</option>        
    </select>
    Thanks for your help

  2. #2
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,350
    I think what you are looking for is
    &amp;

    The HTML entity for "&" is "&amp;" (includes & and ; characters)

  3. #3
    Join Date
    Aug 2010
    Posts
    34
    Thanks, but sadly not. I do not need to encode the character. The cms i'm using breaks when using the & character. This is why I want to use the spelling for and. followed by adding an '&' into the dropdown list later.

  4. #4
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,350

    Exclamation

    Quote Originally Posted by amean_n View Post
    Thanks, but sadly not. I do not need to encode the character. The cms i'm using breaks when using the & character. This is why I want to use the spelling for and. followed by adding an '&' into the dropdown list later.
    That sounds more like a CMS problem than it does JS.
    Are you sure you cannot escape the display with "\&"?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles