View Full Version : I need also to fix this code

01-30-2010, 03:12 PM
Sorry guys,

I am stupid in JS

my smileys inserted verygood in textarea. But if you delete smiley code and need to insert new one the previous code will be there.

<script type="text/javascript">
function insertSmiley(smiley)
var currentText = document.getElementById("message");
var smileyWithPadding = " " + smiley + " ";
currentText.innerHTML += smileyWithPadding;
<textarea name="message" rows="5" id="message"></textarea>

<img src="interface/bigSmile.gif" onclick="insertSmiley(':-D')" /><br>
<img src="interface/cantLook.gif" onclick="insertSmiley(':-P')" />
<img src="interface/cry.gif" onclick="insertSmiley(':=(')" />
<img src="interface/devious.gif" onclick="insertSmiley('=:)')" />
<img src="interface/huh.gif" onclick="insertSmiley('o_0')" />
<img src="interface/knockedOut.gif" onclick="insertSmiley('x-)')" />
<img src="interface/puzzled.gif" onclick="insertSmiley(':-~')" />
<img src="interface/regularSmile.gif" onclick="insertSmiley(':-)')" />
<img src="interface/shocked.gif" onclick="insertSmiley(':-o')" />
<img src="interface/snooze.gif" onclick="insertSmiley('z:-)')" />
<img src="interface/tongue.gif" onclick="insertSmiley(':-P')" />
<img src="interface/unsure.gif" onclick="insertSmiley(':-/')" />
<img src="interface/upset.gif" onclick="insertSmiley(':-(')" />

01-30-2010, 03:33 PM
From the guidelines (http://www.codingforums.com/postguide.htm):

2) Type in a subject that summarizes your question- A great way to turn off other members wanting to help you is to type an incomplete or silly subject for your post.

02-02-2010, 08:53 PM
Shouldn't it be like:

currentText.value += smileyWithPadding;