hi there i am making a scrap book application in which i have to populate the smilies as soon as they are written now i am using the textarea to write the input text for the scrap currently i am trying to just achieve it so i am using only 2 smilies but i am not getting it right here is my code
[code=javascript]
<script type="text/javascript" language="javas cript">
var prev="";
function emticn(){
if(document.get ElementById('sc rap').value!="" ){
var txt=document.ge tElementById('s crap').innerHTM L;
prev=txt;
var replaced=prev.r eplace(":)","<i mg src='goggle.gif ' alt=':)' />");
document.getEle mentById('scrap ').innerHTML=re placed;
}
}
</script>
[/code]
[code=html]
<body onload="documen t.getElementByI d('scrap').focu s();">
Original:<texta rea rows="7" onkeyup="emticn ();" name="scrap" id="scrap"></textarea>
<div id="resdiv"></div>
</body>
[/code]
the error code that i am recieving is
"unknown runtime error on line 13 "
which is the javascript line [code=javascript]
document.getEle mentById('scrap ').innerHTML=re placed;
[/code]
which i think is because i am using innerHTML to populate the image tag inside the textarea and if i use the property
.value instead of ".innerHTML "
then it does not give me error but infact it does not show me the image but he source code of that image that is
[code=html]
<img src='goggle.gif ' alt=':)'>
[/code]
can somebody help me in this regard that what approach should i use and if ia m going he right way to accomplish this thing
regards,
omer
[code=javascript]
<script type="text/javascript" language="javas cript">
var prev="";
function emticn(){
if(document.get ElementById('sc rap').value!="" ){
var txt=document.ge tElementById('s crap').innerHTM L;
prev=txt;
var replaced=prev.r eplace(":)","<i mg src='goggle.gif ' alt=':)' />");
document.getEle mentById('scrap ').innerHTML=re placed;
}
}
</script>
[/code]
[code=html]
<body onload="documen t.getElementByI d('scrap').focu s();">
Original:<texta rea rows="7" onkeyup="emticn ();" name="scrap" id="scrap"></textarea>
<div id="resdiv"></div>
</body>
[/code]
the error code that i am recieving is
"unknown runtime error on line 13 "
which is the javascript line [code=javascript]
document.getEle mentById('scrap ').innerHTML=re placed;
[/code]
which i think is because i am using innerHTML to populate the image tag inside the textarea and if i use the property
.value instead of ".innerHTML "
then it does not give me error but infact it does not show me the image but he source code of that image that is
[code=html]
<img src='goggle.gif ' alt=':)'>
[/code]
can somebody help me in this regard that what approach should i use and if ia m going he right way to accomplish this thing
regards,
omer
Comment