Note that there are some explanatory texts on larger screens.

plurals
  1. POreplace multiple texts from string javascript
    primarykey
    data
    text
    <p>hello there i'm trying to replace a list of selected words with images.... soo i tried the below code..</p> <pre><code>function replaceTextWithEmoticon(text) { return text.replace("[[happybirthday]]","&lt;img src='smileys/birthday.gif' style='height:17px;margin-top:1px;'/&gt;"); return text.replace(":s","&lt;img src='smileys/blue.gif' style='height:17px;margin-top:1px;'/&gt;"); return text.replace(":%","&lt;img src='smileys/blush.gif' style='height:17px;margin-top:1px;'/&gt;"); return text.replace("[[boo]]","&lt;img src='smileys/boo.gif' style='height:17px;margin-top:1px;'/&gt;"); return text.replace(":&gt;","&lt;img src='smileys/book.gif' style='height:17px;margin-top:1px;'/&gt;"); return text.replace("[[busted]]","&lt;img src='smileys/busted.gif' style='height:17px;margin-top:1px;'/&gt;"); return text.replace(":*:)","&lt;img src='smileys/cheekkiss.gif' style='height:17px;margin-top:1px;'/&gt;"); return text.replace("[[goodnight]]","&lt;img src='smileys/goodnight.gif' style='height:17px;margin-top:1px;'/&gt;"); return text.replace("[[newhere]]","&lt;img src='smileys/newhere.gif' style='height:17px;margin-top:1px;'/&gt;"); return text.replace("[[nicethread]]","&lt;img src='smileys/nicethread.gif' style='height:17px;margin-top:1px;'/&gt;"); return text.replace("[[nospam]]","&lt;img src='smileys/nospamhere.gif' style='height:17px;margin-top:1px;'/&gt;"); return text.replace("[[offtopic]]","&lt;img src='smileys/offtopic.gif' style='height:17px;margin-top:1px;'/&gt;"); return text.replace("0:)","&lt;img src='smileys/smiley-angelic002.gif' style='height:17px;margin-top:1px;'/&gt;"); return text.replace("^^'","&lt;img src='smileys/smiley-ashamed004.gif' style='height:17px;margin-top:1px;'/&gt;"); return text.replace("E:|","&lt;img src='smileys/smiley-confused001.gif' style='height:17px;margin-top:1px;'/&gt;"); return text.replace("[:|","&lt;img src='smileys/smiley-confused002.gif' style='height:17px;margin-top:1px;'/&gt;"); return text.replace("v:(v","&lt;img src='smileys/smiley-confused005.gif' style='height:17px;margin-top:1px;'/&gt;"); return text.replace("v0v","&lt;img src='smileys/smiley-confused013.gif' style='height:17px;margin-top:1px;'/&gt;"); return text.replace("B)","&lt;img src='smileys/smiley-cool02.gif' style='height:17px;margin-top:1px;'/&gt;"); return text.replace("[[dancewithpartner]]","&lt;img src='smileys/smiley-dance012.gif' style='height:17px;margin-top:1px;'/&gt;"); return text.replace("[[buttdance]]","&lt;img src='smileys/smiley-dance019.gif' style='height:17px;margin-top:1px;'/&gt;"); return text.replace("3:)","&lt;img src='smileys/smiley-devil03.gif' style='height:17px;margin-top:1px;'/&gt;"); return text.replace("[[excited]]","&lt;img src='smileys/smiley-excited001.gif' style='height:17px;margin-top:1px;'/&gt;"); return text.replace("[[fartsingle]]","&lt;img src='smileys/smiley-fart004.gif' style='height:17px;margin-top:1px;'/&gt;"); return text.replace("[[fartdouble]]","&lt;img src='smileys/smiley-fart005.gif' style='height:17px;margin-top:1px;'/&gt;"); return text.replace("[[midfing]]","&lt;img src='smileys/smiley-finger005.gif' style='height:17px;margin-top:1px;'/&gt;"); return text.replace("[[cheerleader]]","&lt;img src='smileys/smiley-gen013.gif' style='height:17px;margin-top:1px;'/&gt;"); return text.replace("[[bgfight]]","&lt;img src='smileys/smiley-gen041.gif' style='height:17px;margin-top:1px;'/&gt;"); return text.replace("[[score]]","&lt;img src='smileys/smiley-gen055.gif' style='height:17px;margin-top:1px;'/&gt;"); return text.replace("[[thumbdown]]","&lt;img src='smileys/smiley-gen073.gif' style='height:17px;margin-top:1px;'/&gt;"); return text.replace("[[musichappy]]","&lt;img src='smileys/smiley-happy011.gif' style='height:17px;margin-top:1px;'/&gt;"); return text.replace("[[wave]]","&lt;img src='smileys/smiley-happy020.gif' style='height:17px;margin-top:1px;'/&gt;"); return text.replace(";)","&lt;img src='smileys/smiley-happy112.gif' style='height:17px;margin-top:1px;'/&gt;"); return text.replace(":)","&lt;img src='smileys/smiley-happy119.gif' style='height:17px;margin-top:1px;'/&gt;"); return text.replace("[[brushnails]]","&lt;img src='smileys/smiley-happy120.gif' style='height:17px;margin-top:1px;'/&gt;"); return text.replace("[[backhug]]","&lt;img src='smileys/smiley-hug001.gif' style='height:17px;margin-top:1px;'/&gt;"); return text.replace("[[friendshi5]]","&lt;img src='smileys/smiley-hug004.gif' style='height:17px;margin-top:1px;'/&gt;"); return text.replace("[[makehappy]]","&lt;img src='smileys/smiley-hug005.gif' style='height:17px;margin-top:1px;'/&gt;"); return text.replace("[[bfgfhug]]","&lt;img src='smileys/smiley-hug006.gif' style='height:17px;margin-top:1px;'/&gt;"); return text.replace("[[lovehug]]","&lt;img src='smileys/smiley-hug014.gif' style='height:17px;margin-top:1px;'/&gt;"); return text.replace("[[naughty]]","&lt;img src='smileys/smiley-hug015.gif' style='height:17px;margin-top:1px;'/&gt;"); return text.replace("[[laughhard]]","&lt;img src='smileys/smiley-laughing001.gif' style='height:17px;margin-top:1px;'/&gt;"); return text.replace("[[laughnormal]]","&lt;img src='smileys/smiley-laughing002.gif' style='height:17px;margin-top:1px;'/&gt;"); return text.replace("[[iluvu]]","&lt;img src='smileys/smiley-love001.gif' style='height:17px;margin-top:1px;'/&gt;"); return text.replace("[[kisshand]]","&lt;img src='smileys/smiley-love007.gif' style='height:17px;margin-top:1px;'/&gt;"); return text.replace("[[coupleluv]]","&lt;img src='smileys/smiley-love010.gif' style='height:17px;margin-top:1px;'/&gt;"); return text.replace("[[cheekkiss]]","&lt;img src='smileys/smiley-love011.gif' style='height:17px;margin-top:1px;'/&gt;"); return text.replace("&lt;3","&lt;img src='smileys/smiley-love018.gif' style='height:17px;margin-top:1px;'/&gt;"); return text.replace("[[candlelightdinner]]","&lt;img src='smileys/smiley-love019.gif' style='height:17px;margin-top:1px;'/&gt;"); return text.replace("[[intenseluv]]","&lt;img src='smileys/smiley-love022.gif' style='height:17px;margin-top:1px;'/&gt;"); return text.replace("[[merrygoround]]","&lt;img src='smileys/smiley-love025.gif' style='height:17px;margin-top:1px;'/&gt;"); return text.replace("[[toiletplungerkiss]]","&lt;img src='smileys/smiley-love027.gif' style='height:17px;margin-top:1px;'/&gt;"); return text.replace("[[kissinglips]]","&lt;img src='smileys/smiley-love028.gif' style='height:17px;margin-top:1px;'/&gt;"); return text.replace(":(","&lt;img src='smileys/smiley-sad056.gif' style='height:17px;margin-top:1px;'/&gt;"); return text.replace(":P","&lt;img src='smileys/smiley-taunt002.gif' style='height:17px;margin-top:1px;'/&gt;"); return text.replace(":p","&lt;img src='smileys/smiley-taunt002.gif' style='height:17px;margin-top:1px;'/&gt;"); return text.replace(":P|","&lt;img src='smileys/smiley-taunt014.gif' style='height:17px;margin-top:1px;'/&gt;"); return text.replace(":p|","&lt;img src='smileys/smiley-taunt014.gif' style='height:17px;margin-top:1px;'/&gt;"); return text.replace("[[welcome]]","&lt;img src='smileys/welcome.gif' style='height:17px;margin-top:1px;'/&gt;"); return text.replace("[[wtf]]","&lt;img src='smileys/wtf.gif' style='height:17px;margin-top:1px;'/&gt;"); } </code></pre> <p>the above code only replaces the <code>"[[happybirthday]]"</code> in the string and nothing else.. and when there are more than one <code>[[happybirthday]]</code> it only replaces the first one... can any one please tell me what i have done wrong here.. ? thanks in advance.. :)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload