|
-
Sep 6th, 2004, 05:21 AM
#1
Thread Starter
PowerPoster
Adding Text/Images to Textarea *SOLVED*
I posted this question
"Not sure how to explain this so will use this forum as an example. When creating a new post or replying to an existing one if you click one of the smilies it is then added to the message being typed. I am creating a similar process but don't know how to add the smilie to the textarea once it has been clicked.
This is the reply I got which works fine but how can I made (rolleyes) a variable so I can insert anything??
Code:
<html>
<head>
<title>
Example - by Phreak
</title>
<script language="javascript">
function addittotextarea()
{
form1.text1.value += ":rolleyes:";
}
</script>
</head>
<body>
<form name="form1">
<textarea name="text1"></textarea>
<input type="button" onClick="addittotextarea()">
</form>
</body>
</html>
Last edited by lintz; Sep 6th, 2004 at 06:32 AM.
-
Sep 6th, 2004, 05:45 AM
#2
Aah, see... there's your problem right there. 
Code:
function addittotextarea()
{
form1.text1.value += ":something:";
}
Is about right.
When you insert :something: in the textarea, it's upto the server-side script to parse that, and replace it with an actual <img> tag when it is being displayed to the user again. Do you see the difference?
-
Sep 6th, 2004, 05:50 AM
#3
Thread Starter
PowerPoster
I understand that part - my question was how to make ":something:" a variable so I don't have to have a seperate function to display each smilie.
-
Sep 6th, 2004, 05:54 AM
#4
You don't need a separate function for each smilie in the first place. What are you talking about?
-
Sep 6th, 2004, 06:08 AM
#5
Thread Starter
PowerPoster
If I don't need a seperate function to add each smilie to the textarea then how do I use the below function to add a different smilie or is there another (better) way to do it??
PHP Code:
//This is an example of how my smilies are displayed
"<img src=\"smilie1.gif\" alt=\"bigsmile\" onClick=\"addittotextarea()\">";
//This is the function used to display the smilie in the textarea
function addittotextarea()
{
form1.text1.value += ":something:";
}
-
Sep 6th, 2004, 06:11 AM
#6
Frenzied Member
Code:
function addittotextarea(smiley)
{
form1.text1.value += smiley;
}
Then call your function with the smiley you would like to add:
Code:
addittotextarea(":something:");
Is that what you mean?
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
-
Sep 6th, 2004, 06:16 AM
#7
Yes, I think that's what he means.
-
Sep 6th, 2004, 06:31 AM
#8
Thread Starter
PowerPoster
Thanks Jop - that was exactly what I was tryng to do.
I got it working!
-
Sep 6th, 2004, 07:20 AM
#9
Modern boards are more sophisticated, though. They query the position of the cursor and insert the smiley there.
That takes different approaches for different browsers, though.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Sep 9th, 2004, 12:11 AM
#10
Originally posted by mendhak
Aah, see... there's your problem right there. 
*slap* 
Phreak
Visual Studio 6, Visual Studio.NET 2005, MASM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|