ReMBReT
12-18-2003, 06:28 PM
I'm a newbie in javascript, so this justify my post.
I'm trying to make my this script working, it's supposed to do the same as in this forum, clicking on a smilie, then translating it into text in a textarea.
<script language="JavaScript" type="text/javascript">
function AddText(defaultText,loc){
if (document.adminwork.loc.createTextRange){
var text;
document.adminwork.loc.focus(document.adminwork.loc.caretPos);
document.adminwork.loc.caretPos = document.selection.createRange().duplicate();
if(document.adminwork.loc.caretPos.text.length>0){
document.adminwork.loc.caretPos.text = document.adminwork.loc.caretPos.text;
}
else{
document.adminwork.loc.caretPos.text = defaultText;
}
}
else {document.adminwork.loc.value += defaultText;}
}
</script>
So that's the function, in the <head> of my page.
Now, that's my image, in PHP.
<?
$loc = 'newsmessage';
echo '<img src="smilies/alone.gif" style="cursor:hand" onclick="javascript:AddText(\'[smi01]\',\''.$loc.'\');" align="absmiddle">';
?>
My form is named 'adminwork' and the textarea is named 'newsmessage'.
So what I want this to do is when we click on alone.gif, it writes smi[01] into the textarea 'newsmessage' in the form 'adminwork'. What's not working!?!?!!
Thanks a lot
:D
I'm trying to make my this script working, it's supposed to do the same as in this forum, clicking on a smilie, then translating it into text in a textarea.
<script language="JavaScript" type="text/javascript">
function AddText(defaultText,loc){
if (document.adminwork.loc.createTextRange){
var text;
document.adminwork.loc.focus(document.adminwork.loc.caretPos);
document.adminwork.loc.caretPos = document.selection.createRange().duplicate();
if(document.adminwork.loc.caretPos.text.length>0){
document.adminwork.loc.caretPos.text = document.adminwork.loc.caretPos.text;
}
else{
document.adminwork.loc.caretPos.text = defaultText;
}
}
else {document.adminwork.loc.value += defaultText;}
}
</script>
So that's the function, in the <head> of my page.
Now, that's my image, in PHP.
<?
$loc = 'newsmessage';
echo '<img src="smilies/alone.gif" style="cursor:hand" onclick="javascript:AddText(\'[smi01]\',\''.$loc.'\');" align="absmiddle">';
?>
My form is named 'adminwork' and the textarea is named 'newsmessage'.
So what I want this to do is when we click on alone.gif, it writes smi[01] into the textarea 'newsmessage' in the form 'adminwork'. What's not working!?!?!!
Thanks a lot
:D