AndrewBacca
02-01-2003, 01:53 PM
The smiles work, when you click the images the text appears here how? Ive been tring for ages with no luck, so some code or help would be great
thankyou
Andrew :D
thankyou
Andrew :D
|
Click to See Complete Forum and Search --> : how do... AndrewBacca 02-01-2003, 01:53 PM The smiles work, when you click the images the text appears here how? Ive been tring for ages with no luck, so some code or help would be great thankyou Andrew :D Zach Elfers 02-01-2003, 02:13 PM Do you mean how does the text appear when you click the smile? <script type="text/JavaScript"> <!-- function addSmile(smiley) { document.formName.fieldName.value += smiley; } //--> </script> ... <form name="formName"> <a onClick="addSmile(':)');"><img src="smiley01.gif" border="0"></a><a onClick="addSmile(':P');"><img src="smiley02.gif"></a><a onClick="addSmile(':(');"><img src="smiley03.gif"></a> <p> <textarea name="fieldName" cols="20" rows="6"></textarea> </form> AndrewBacca 02-01-2003, 02:31 PM cheers :D Andrew AndrewBacca 02-01-2003, 02:48 PM how can I make it so that the text is placed at the position of the cursor before you click the button, cos its only appearing at the end of the text? Andrew AndrewBacca 02-04-2003, 03:28 AM ive got it working heres the code so if anyone else wants to do the samething its here :) <HTML> <HEAD> <TITLE></TITLE> <script LANGUAGE="JavaScript"> function storeCaret (textEl) { if (textEl.createTextRange) textEl.caretPos = document.selection.createRange().duplicate(); } function insertAtCaret (textEl, text) { if (textEl.createTextRange && textEl.caretPos) { var caretPos = textEl.caretPos; caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text; } else textEl.value = text; } </script> </HEAD> <BODY> <FORM> <textarea rows="5" name="ta_message" cols="20"ONSELECT="storeCaret(this);"ONCLICK="storeCaret(this);"ONKEYUP="storeCaret(this);"></textarea> <INPUT TYPE="button" VALUE="Click Me" ONCLICK="insertAtCaret(this.form.ta_message,'Appearing text');"> </FORM> </BODY> </HTML> webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved. |