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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • descds

    #1

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

    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.commen t.post.value;
    this.code = code;
    document.commen t.post.value = pretext + code;
    }
    //-->
    </script>
    <b>Comment on this movie:</b>
    <form name="comment" method="post" action="news.ph p"> <textarea
    name="post" wrap="hard" rows="8" cols="30"></textarea></form>
    <img src="../../forum/images/smiles/icon_biggrin.gi f" alt=":)"
    onclick="addsmi ley(':)')" style="border: 0px solid ; width: 15px;
    height: 15px; cursor: pointer;">
    </body>
    </html>
    ------------------------------------------------------------------------------
    Ive tried setting WRAP to Virtual / HARD / SOFT / Physical etc and it
    still insists on not wrapping from the javascript ... Anyone any ideas ???

  • RobG

    #2
    Re: Smiley Click picker using Javascript and FORM woes .. Pleasehelp ...

    descds wrote:

    <--snip-->[color=blue]
    > Ive tried setting WRAP to Virtual / HARD / SOFT / Physical etc and it
    > still insists on not wrapping from the javascript ... Anyone any ideas ???
    >[/color]

    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="addsmi ley(':) ')"



    Rob.

    Comment

    • descds descds

      #3
      Re: Smiley Click picker using Javascript and FORM woes .. Please help ...

      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 :)

      *** Sent via Developersdex http://www.developersdex.com ***
      Don't just participate in USENET...get rewarded for it!

      Comment

      • descds

        #4
        Re: Smiley Click picker using Javascript and FORM woes .. Pleasehelp ...

        RobG wrote:[color=blue]
        > descds wrote:
        >
        > <--snip-->
        >[color=green]
        >> Ive tried setting WRAP to Virtual / HARD / SOFT / Physical etc and it
        >> still insists on not wrapping from the javascript ... Anyone any ideas
        >> ???
        >>[/color]
        >
        > 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="addsmi ley(':) ')"
        >
        >
        >
        > Rob.[/color]

        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 :)

        Comment

        Working...