Smiley Click picker using Javascript and FORM woes .. Please help...

D

descds

OK im prety much a newbie at PHP but it has me hooked.

Im writing a comment system for one of our modules on phpnuke. Its all
going very well, well should i say WAS going very well :)

Ok all the comments work etc and everything is intergrated nicely in the
database. Now im parsing the comments back out to the user and replacing
string like :) with emoticons etc. It works perfectly and i'm seriously
pleased with myself (ok ok remember i said i was new at this :) .....

Now the issue i have is a silly one. I want to present the form input
for the comments in pretty much similair ways to phpbb does on a new
post. I.e present BBCODE icons and smileys that can be clicked and it
inserts into the FORM field ... I have a working javascript that does
just that but try as i might the darn thing will NOT wrap a FORM (even
if wrapping is on). This seems more a MOZILLA problem than IE ( wraps in
that). So if i keep on hitting the same icon again and again it will not
wrap and presents a scrollbar that keeps on going. The actual FORM will
wrap if i insert text inside it manually however so maybe its a
javascript error after all ??

Anyway im hoping someone somewhere can shed some light on this. Here the
test code.
-----------------------------------------------------------------------------
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="content-type">
<title></title>
</head>
<body>
<script type="text/javascript">
<!--
function addsmiley(code)
{
var pretext = document.comment.post.value;
this.code = code;
document.comment.post.value = pretext + code;
}
//-->
</script>
<b>Comment on this movie:</b>
<form name="comment" method="post" action="news.php"> <textarea
name="post" wrap="hard" rows="8" cols="30"></textarea></form>
<img src="../../forum/images/smiles/icon_biggrin.gif" alt=":)"
onclick="addsmiley(':)')" style="border: 0px solid ; width: 15px;
height: 15px; cursor: pointer;">
</body>
</html>
 
R

RobG

descds wrote:

Ive tried setting WRAP to Virtual / HARD / SOFT / Physical etc and it
still insists on not wrapping from the javascript ... Anyone any ideas ???

Firefox (and I presume any other Geko-based browser) seems to only wrap if there's a space, it won't wrap between characters. Put a space before or after the smiley so that your onclick becomes:

onclick="addsmiley(':) ')"



Rob.
 
D

descds descds

oh my i cant believe it was tha simple :) ive spent hours on this simple
thing and its just a space :) mYes works perfectly now. Can not thank
you enough .......

Thanks very much rob ... Finally i can put closure on something that i
assumed was going to be extremely simple :)
 
D

descds

RobG said:
descds wrote:



Firefox (and I presume any other Geko-based browser) seems to only wrap
if there's a space, it won't wrap between characters. Put a space
before or after the smiley so that your onclick becomes:

onclick="addsmiley(':) ')"



Rob.

oh my i can't believe it was that simple :) i've spent hours on this
simple thing and its just a space :) Yes works perfectly now. Can not
thank you enough .......

Thanks very much rob ... Finally i can put closure on something that i
assumed was going to be extremely simple :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,024
Latest member
ARDU_PROgrammER

Latest Threads

Top