Archbob Posted March 4, 2007 Share Posted March 4, 2007 Hi,I've just implemented a WYSIWYG into one of my PHP applications but now the clickable smilies don't work. I had this code before: print "<textarea rows='6' name='post' cols='45'></textarea><br><br>"; print "<input type='checkbox' name='nosmiley'> Disable Smilies<br><br>"; print "<input type='submit' name='reply' value='reply'>"; print "</form>"; print "Clickable Smilies<br>"; print "<a onClick=\"addSmiley('')\"><img src='images/smile.gif'></a> "; print "<a onClick=\"addSmiley(':blush')\"><img src='images/blush.gif'></a> "; print "<a onClick=\"addSmiley(':angry')\"><img src='images/angry.gif'></a> "; print "<a onClick=\"addSmiley(':shocked')\"><img src='images/shocked.gif'></a> "; print "<a onClick=\"addSmiley(':cool')\"><img src='images/cool.gif'></a> "; print "<a onclick=\"addSmiley(':{blink}')\"><img src='images/winking.gif'></a>"; print "<A onclick=\"addSmiley('{clover}')\"><img src='images/clover.gif'></a>"; print "<a onclick=\"addSmiley(':[glasses]')\"><img src='images/glasses.gif'></a>"; print "<a onclick=\"addSmiley(':[barf]')\"><img src='images/barf.gif'></a>"; print "<a onclick=\"addSmiley(':[reallymad]')\"><img src='images/mad.gif'></a><br>"; print "<a onclick=\"addSmiley(':[normal]')\"><img src='../smiley/normal.gif'></a>"; print "<a onclick=\"addSmiley(':[inqu]')\"><img src='../smiley/inquisitive.gif'></a>"; print "<a onclick=\"addSmiley(':[happyinlove]')\"><img src='../smiley/happyinlove.gif'></a>"; print "<a onclick=\"addSmiley(':[sadinlove]')\"><img src='../smiley/sadinlove.gif'></a>"; print "<a onclick=\"addSmiley(':[normalinlove]')\"><img src='../smiley/normalaboutlove.gif'></a><br>"; print "<a onclick=\"addSmiley(':[bangry]')\"><img src='../smiley/angry.jpg'></a>"; print "<a onclick=\"addSmiley(':[grin]')\"><img src='../smiley/grin.jpg'></a>"; print "<a onclick=\"addSmiley(':[sadness]')\"><img src='../smiley/sadness.jpg'></a>"; print "<a onclick=\"addSmiley(':[smilies]')\"><img src='../smiley/smiles.jpg'></a>"; print "<a onclick=\"addSmiley(':[winking]')\"><img src='../smiley/winking.jpg'></a><br>"; print "<script language=\"JavaScript\" type=\"text/javascript\">\n"; print "function addSmiley(textToAdd)\n"; print "{\n"; print "document.form.post.value += textToAdd;"; print "document.form.post.focus();\n"; print "}\n"; print "</script>\n"; But now I have this: print "<textarea id='post' rows='6' name='post' cols='45'></textarea><br><br>"; print '<script language="JavaScript">'; print "generate_wysiwyg('post')"; print "</script>"; print "<input type='checkbox' name='nosmiley'> Disable Smilies<br><br>"; print "<input type='submit' name='submitpost' value='Post'>"; print "</form><br><br>"; print "Clickable Smilies<br>"; print "<a onClick=\"addSmiley('')\"><img src='images/smile.gif'></a> "; print "<a onClick=\"addSmiley(':blush')\"><img src='images/blush.gif'></a> "; print "<a onClick=\"addSmiley(':angry')\"><img src='images/angry.gif'></a> "; print "<a onClick=\"addSmiley(':shocked')\"><img src='images/shocked.gif'></a> "; print "<a onClick=\"addSmiley(':cool')\"><img src='images/cool.gif'></a> "; print "<a onclick=\"addSmiley(':{blink}')\"><img src='images/winking.gif'></a>"; print "<A onclick=\"addSmiley('{clover}')\"><img src='images/clover.gif'></a>"; print "<a onclick=\"addSmiley(':[glasses]')\"><img src='images/glasses.gif'></a>"; print "<a onclick=\"addSmiley(':[barf]')\"><img src='images/barf.gif'></a>"; print "<a onclick=\"addSmiley(':[reallymad]')\"><img src='images/mad.gif'></a><br>"; print "<a onclick=\"addSmiley(':[normal]')\"><img src='../smiley/normal.gif'></a>"; print "<a onclick=\"addSmiley(':[inqu]')\"><img src='../smiley/inquisitive.gif'></a>"; print "<a onclick=\"addSmiley(':[happyinlove]')\"><img src='../smiley/happyinlove.gif'></a>"; print "<a onclick=\"addSmiley(':[sadinlove]')\"><img src='../smiley/sadinlove.gif'></a>"; print "<a onclick=\"addSmiley(':[normalinlove]')\"><img src='../smiley/normalaboutlove.gif'></a><br>"; print "<a onclick=\"addSmiley(':[bangry]')\"><img src='../smiley/angry.jpg'></a>"; print "<a onclick=\"addSmiley(':[grin]')\"><img src='../smiley/grin.jpg'></a>"; print "<a onclick=\"addSmiley(':[sadness]')\"><img src='../smiley/sadness.jpg'></a>"; print "<a onclick=\"addSmiley(':[smilies]')\"><img src='../smiley/smiles.jpg'></a>"; print "<a onclick=\"addSmiley(':[winking]')\"><img src='../smiley/winking.jpg'></a><br>"; print "<script language=\"JavaScript\" type=\"text/javascript\">\n"; print "function addSmiley(textToAdd)\n"; print "{\n"; print "document.form.post.value += textToAdd;"; print "document.form.post.focus();\n"; print "}\n"; print "</script>\n"; It gives me a "focus not available or invisible error" when I try to click on the smilies, anybody know why? Quote Link to comment Share on other sites More sharing options...
fenway Posted March 4, 2007 Share Posted March 4, 2007 You can't always give focus, especially to something hidden. Quote Link to comment Share on other sites More sharing options...
Archbob Posted March 5, 2007 Author Share Posted March 5, 2007 So um, how would I add clickable smilies to my textarea then? Quote Link to comment Share on other sites More sharing options...
fenway Posted March 5, 2007 Share Posted March 5, 2007 You can... but you're trying to give focus to the form itself. Quote Link to comment Share on other sites More sharing options...
Archbob Posted March 5, 2007 Author Share Posted March 5, 2007 So how would I add clickable smilies to the above mentioned textarea? Quote Link to comment Share on other sites More sharing options...
fenway Posted March 5, 2007 Share Posted March 5, 2007 Why don't you post the entire script after it's generated, not the PHP version? I already got confused because I didn't see the open form tag... Quote Link to comment Share on other sites More sharing options...
Archbob Posted March 6, 2007 Author Share Posted March 6, 2007 print "<form action='newtopic.php?forumID=$forumID' method='post' name='form'>"; if(isset($_SESSION['user'])) { print "<input type='hidden' name='name' value=$getid3[userID]><br>"; print "<b>Name:</b> $user<br>"; } else { $getguest="SELECT * FROM b_users WHERE username='Guest'"; $getguest2=mysql_query($getguest); $getguest3=mysql_fetch_array($getguest2); print "<input type='hidden' name='name' value='$getguest3[userID]'><br>"; print "<b>Name:</b> Guest<br>"; } print "<b>Topic:</b><br>"; print "<input type='text' name='title' length='15'><br><br>"; print "<b>Message:</b><br><br>"; print "<textarea id='post' rows='6' name='post' cols='45'></textarea><br><br>"; print '<script language="JavaScript">'; print "generate_wysiwyg('post')"; print "</script>"; print "<input type='checkbox' name='nosmiley'> Disable Smilies<br><br>"; print "<input type='submit' name='submitpost' value='Post'>"; print "</form><br><br>"; print "Clickable Smilies<br>"; print "<a onClick=\"addSmiley('')\"><img src='images/smile.gif'></a> "; print "<a onClick=\"addSmiley(':blush')\"><img src='images/blush.gif'></a> "; print "<a onClick=\"addSmiley(':angry')\"><img src='images/angry.gif'></a> "; print "<a onClick=\"addSmiley(':shocked')\"><img src='images/shocked.gif'></a> "; print "<a onClick=\"addSmiley(':cool')\"><img src='images/cool.gif'></a> "; print "<a onclick=\"addSmiley(':{blink}')\"><img src='images/winking.gif'></a>"; print "<A onclick=\"addSmiley('{clover}')\"><img src='images/clover.gif'></a>"; print "<a onclick=\"addSmiley(':[glasses]')\"><img src='images/glasses.gif'></a>"; print "<a onclick=\"addSmiley(':[barf]')\"><img src='images/barf.gif'></a>"; print "<a onclick=\"addSmiley(':[reallymad]')\"><img src='images/mad.gif'></a><br>"; print "<a onclick=\"addSmiley(':[normal]')\"><img src='../smiley/normal.gif'></a>"; print "<a onclick=\"addSmiley(':[inqu]')\"><img src='../smiley/inquisitive.gif'></a>"; print "<a onclick=\"addSmiley(':[happyinlove]')\"><img src='../smiley/happyinlove.gif'></a>"; print "<a onclick=\"addSmiley(':[sadinlove]')\"><img src='../smiley/sadinlove.gif'></a>"; print "<a onclick=\"addSmiley(':[normalinlove]')\"><img src='../smiley/normalaboutlove.gif'></a><br>"; print "<a onclick=\"addSmiley(':[bangry]')\"><img src='../smiley/angry.jpg'></a>"; print "<a onclick=\"addSmiley(':[grin]')\"><img src='../smiley/grin.jpg'></a>"; print "<a onclick=\"addSmiley(':[sadness]')\"><img src='../smiley/sadness.jpg'></a>"; print "<a onclick=\"addSmiley(':[smilies]')\"><img src='../smiley/smiles.jpg'></a>"; print "<a onclick=\"addSmiley(':[winking]')\"><img src='../smiley/winking.jpg'></a><br>"; print "<script language=\"JavaScript\" type=\"text/javascript\">\n"; print "function addSmiley(textToAdd)\n"; print "{\n"; print "document.form.post.value += textToAdd;"; print "document.form.post.focus();\n"; print "}\n"; print "</script>\n"; Thats my form, its wrapped in PHP but its a pretty basic form. Quote Link to comment Share on other sites More sharing options...
fenway Posted March 7, 2007 Share Posted March 7, 2007 Really, NOT the PHP version... viewsource of your page. Quote Link to comment Share on other sites More sharing options...
Archbob Posted March 8, 2007 Author Share Posted March 8, 2007 Its the same thing with PHP, just less the print command. I'm just telling PHP to prink out the HTML there: <form action='newtopic.php?forumID=$forumID' method='post' name='form'> <b>Topic:</b><br> <input type='text' name='title' length='15'><br><br> <b>Message:</b><br><br> <textarea id='post' rows='6' name='post' cols='45'></textarea><br><br> <script language="JavaScript"> generate_wysiwyg('post') </script> <input type='checkbox' name='nosmiley'> Disable Smilies<br><br> <input type='submit' name='submitpost' value='Post'> </form><br><br> Clickable Smilies<br> <a onClick=\"addSmiley('')\"><img src='images/smile.gif'></a> <a onClick=\"addSmiley(':blush')\"><img src='images/blush.gif'></a> <a onClick=\"addSmiley(':angry')\"><img src='images/angry.gif'></a> <a onClick=\"addSmiley(':shocked')\"><img src='images/shocked.gif'></a> <a onClick=\"addSmiley(':cool')\"><img src='images/cool.gif'></a> <a onclick=\"addSmiley(':{blink}')\"><img src='images/winking.gif'></a> <A onclick=\"addSmiley('{clover}')\"><img src='images/clover.gif'></a> <a onclick=\"addSmiley(':[glasses]')\"><img src='images/glasses.gif'></a> <a onclick=\"addSmiley(':[barf]')\"><img src='images/barf.gif'></a> <a onclick=\"addSmiley(':[reallymad]')\"><img src='images/mad.gif'></a><br> <a onclick=\"addSmiley(':[normal]')\"><img src='../smiley/normal.gif'></a> <a onclick=\"addSmiley(':[inqu]')\"><img src='../smiley/inquisitive.gif'></a> <a onclick=\"addSmiley(':[happyinlove]')\"><img src='../smiley/happyinlove.gif'></a> <a onclick=\"addSmiley(':[sadinlove]')\"><img src='../smiley/sadinlove.gif'></a> <a onclick=\"addSmiley(':[normalinlove]')\"><img src='../smiley/normalaboutlove.gif'></a><br> <a onclick=\"addSmiley(':[bangry]')\"><img src='../smiley/angry.jpg'></a> <a onclick=\"addSmiley(':[grin]')\"><img src='../smiley/grin.jpg'></a> <a onclick=\"addSmiley(':[sadness]')\"><img src='../smiley/sadness.jpg'></a> <a onclick=\"addSmiley(':[smilies]')\"><img src='../smiley/smiles.jpg'></a> <a onclick=\"addSmiley(':[winking]')\"><img src='../smiley/winking.jpg'></a><br> <script language=\"JavaScript\" type=\"text/javascript\"> function addSmiley(textToAdd) {\n document.form.post.value += textToAdd; document.form.post.focus(); } </script> Basically you can see it here: http://www.chipmunk-scripts.com/board/newtopic.php?forumID=36 Don't actually post please because guest posting is turned off. Quote Link to comment Share on other sites More sharing options...
fenway Posted March 8, 2007 Share Posted March 8, 2007 I was hoping to rid myself of all of that unnecessary quoting... but no matter. Maybe I'll get a chance to play later. Quote Link to comment Share on other sites More sharing options...
Archbob Posted March 8, 2007 Author Share Posted March 8, 2007 Basically I need to know how to get the onclick commands to put the characters in my textbox now that the focus is invisible. Quote Link to comment Share on other sites More sharing options...
fenway Posted March 8, 2007 Share Posted March 8, 2007 Which browser is giving you these errors? Quote Link to comment Share on other sites More sharing options...
Archbob Posted March 9, 2007 Author Share Posted March 9, 2007 IE just an error at the bottom of the page. It just doesn't work in FireFox, even though firefox doesn't show a javascript error. Quote Link to comment Share on other sites More sharing options...
fenway Posted March 9, 2007 Share Posted March 9, 2007 Seems to work in FF for me on linux. Quote Link to comment Share on other sites More sharing options...
Archbob Posted March 9, 2007 Author Share Posted March 9, 2007 It does not work on windows in FF or IE. Quote Link to comment Share on other sites More sharing options...
Archbob Posted March 9, 2007 Author Share Posted March 9, 2007 Anyone have an idea why it isn't working when viewing in windows? Quote Link to comment Share on other sites More sharing options...
fenway Posted March 9, 2007 Share Posted March 9, 2007 Well, then I don't know what you mean by focus... my caret ends up right after the smiley in FF. Quote Link to comment Share on other sites More sharing options...
Archbob Posted March 10, 2007 Author Share Posted March 10, 2007 When you click on a smiley in the link I gave, does it actually put the characters into the textbox? Quote Link to comment Share on other sites More sharing options...
fenway Posted March 13, 2007 Share Posted March 13, 2007 Yup. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.