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 -
<script type="text/javascript" language="javascript">
-
var prev="";
-
function emticn(){
-
if(document.getElementById('scrap').value!=""){
-
var txt=document.getElementById('scrap').innerHTML;
-
prev=txt;
-
var replaced=prev.replace(":)","<img src='goggle.gif' alt=':)' />");
-
document.getElementById('scrap').innerHTML=replaced;
-
}
-
-
}
-
</script>
-
-
<body onload="document.getElementById('scrap').focus();">
-
Original:<textarea rows="7" onkeyup="emticn();" name="scrap" id="scrap"></textarea>
-
<div id="resdiv"></div>
-
</body>
-
the error code that i am recieving is "unknown runtime error on line 13 "
which is the javascript line -
document.getElementById('scrap').innerHTML=replaced;
-
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 -
<img src='goggle.gif' alt=':)'>
-
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
11 1643
Use execCommand with iframes. See the test page for an example.
I am guessing part of the problem is that this line :
Should be :
I am guessing part of the problem is that this line :
Should be :
it is not an error it is just a typo mistake here on the forum , whereas in my code it is written like
:)
Use execCommand with iframes. See the test page for an example.
:( aint getting any thing from here its too messy :( can anyone guide me according to the code i have written
regards,
omer
Well, it's not going to work with the code you've got.
You could, however, create a preview pane (e.g. a div) which could display the smilies that you type in the textarea.
Well, it's not going to work with the code you've got.
You could, however, create a preview pane (e.g. a div) which could display the smilies that you type in the textarea.
yeah ihave done that already and for that same purpose i have made that "resdiv"
i just omitted that part of code and changed the line -
document.getElementById('resdiv').innerHTML=replaced;
-
TO
-
document.getElementById('scrap').innerHTML=replace d;
-
because i wanted to populate the emoticons in the text field but it doesnot seem to be possible, but on the other hand if you see my javascript code there is still a problem in it even if i use the div for the preview,it just makes each emoticon work once means,
if i enter :) for the first time then it is ok,it populates the icon for this smiley but if i again write :) it shows it as is does not populate it again same is the case for all other smilies i hope i amnot confusing you,
thanks for any help in advance,
regards,
omer
That's probably because you have ":)" as an alt attribute for the emoticon, so that is what's being replaced!
That's probably because you have ":)" as an alt attribute for the emoticon, so that is what's being replaced!
nah em sorry that isnt it i have tried it too it will go to the alt=':)' only if the image is not found or loaded,that didnt solved the problem
No, I meant the text contains :) when you replace :) with an emoticon. See this code: - <img src='goggle.gif' alt=':)'>
The alt attribute has the :) contained within it. When you replace ":)", it may be replacing the alt text rather than the second ":)".
Can you show some demonstrable code which can be tested.
No, I meant the text contains :) when you replace :) with an emoticon. See this code: - <img src='goggle.gif' alt=':)'>
The alt attribute has the :) contained within it. When you replace ":)", it may be replacing the alt text rather than the second ":)".
Can you show some demonstrable code which can be tested.
no it wasnt doing anything like that i was doing it the wrong way , idid it today write as i desired here watch this code -
<script type="text/javascript" language="javascript">
-
function stripper(str){
-
var arraysigns=new Array();
-
var arrayname=new Array();
-
arraysigns=["8)","*)",":@",":#",":o",":e",":s","*p","-p",":)",":D",":p",":$",":(",":w",":*",":x",":-","8x","8|",":6",":&","8*","$)","'(","g("];
-
arrayname=["goggle.gif","love.gif","hot.gif","sad.gif","shock.gif","wacked.gif","pissed.gif","horny.gif","dizzy.gif","smile.gif","happyteeth.gif","tounge.gif","shy.gif","disap.gif","wot.gif","kiss.gif","shutup.gif","holiday.gif","army.gif","nered.gif","devil.gif","sadangle.gif","kissdead.gif","money.gif","money.gif","swet.gif"];
-
var stringlength=str.length;
-
for(var j=0;j<arraysigns.length;j++){
-
for(var k=0;k<stringlength;k++){
-
str=str.replace(arraysigns[j],"<img src='images/"+arrayname[j]+"'>");
-
}
-
}
-
return str;
-
}
-
var replaced="";
-
function emticn(){
-
if(document.getElementById('scrap').value!=""){
-
var txt=document.getElementById('scrap').innerHTML;
-
replaced=stripper(txt);
-
document.getElementById('resdiv').innerHTML=replaced;
-
}
-
}
-
-
<body onload="document.getElementById('scrap').focus();">
-
<form name="emoticon" id="emoticon" method="post">
-
<tr><td align="center" valign="top">Original:</td><td align="center" valign="top"><textarea cols="20" rows="7" onkeyup="emticn();" name="scrap" id="scrap"></textarea></td></tr>
-
<tr><td><div id="resdiv"></div></td></tr>
-
</form>
-
</body>
-
-
Use value instead of innerHTML and your code should work - I see you've removed the alt.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Killer42 |
last post by:
Hi all.
Where can I find a list of the smilies supported by the vb code syntax? The "list" provided in the FAQ just contains a message describing briefly what a smiley is.
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |