shebbycs Posted October 24, 2011 Share Posted October 24, 2011 This one im took from php print "<form action='registration.php' method='post'onsubmit='return msg();'>"; print "Your message:<br>"; print "<textarea name='message' cols='40' rows='2'></textarea><br>"; print "<a onClick=\"addSmiley('')\"><img src='smile.gif'></a> "; print "<a onClick=\"addSmiley('')\"><img src='blush.gif'></a> "; print "<a onClick=\"addSmiley('')\"><img src='images/wink.gif'></a> "; print "<input type='submit' name='submit' value='Set Name'></form>"; print "<script language=\"Java Script\" type=\"text/javascript\">\n"; print "function addSmiley(a)\n"; print "{\n"; print "document.form.message.value += a;"; print "document.form.message.focus();\n"; print "}\n"; print "</script>\n"; print "<br><br>"; and i converted it to html <html> <form action='registration.php' method='post'> Your message:<br><textarea name='message' cols='40' rows='2'></textarea><br> <a onClick=\"addSmiley('')\"><img src='smile.gif'></a> <a onClick=\"addSmiley('')\"><img src='blush.gif'></a> <a onClick=\"addSmiley('')\"><img src='images/wink.gif'></a> <input type='submit' name='submit' value='Set Name'></form> <script type="text/javascript">+"\n" function addSmiley(a)+"\n" { "\n" document.form.message.value + = a document.form.message.focus()+"\n" } "\n" </script> "\n" <br> <br> </html> but that html problem is im cannot integrate the javascript im means canot click the smiley button la may i know what is wrong Quote Link to comment https://forums.phpfreaks.com/topic/249713-how-to-make-the-smiley-clickable/ Share on other sites More sharing options...
ManiacDan Posted October 24, 2011 Share Posted October 24, 2011 Remove all the +"\n" from your javascript. Also, use a javascript debugger. EVERY modern browser has one either built-in or readily available. -Dan Quote Link to comment https://forums.phpfreaks.com/topic/249713-how-to-make-the-smiley-clickable/#findComment-1281777 Share on other sites More sharing options...
shebbycs Posted October 24, 2011 Author Share Posted October 24, 2011 <html> <head> </head> <body> <form action='registration.php' method='post'> Your message:<br><textarea name='message' cols='40' rows='2'></textarea><br> <a onClick=\"addSmiley('')\"><img src='smile.gif'></a> <a onClick=\"addSmiley('')\"><img src='blush.gif'></a> <a onClick=\"addSmiley('')\"><img src='images/wink.gif'></a> <input type='submit' name='submit' value='Set Name'></form> <script type="text/javascript"> function addSmiley(a) { document.form.message.value + = a document.form.message.focus() } </script> <br> <br> </body> </html> after im had clear that /n what im need to do as im din get that javabuilder meaning Quote Link to comment https://forums.phpfreaks.com/topic/249713-how-to-make-the-smiley-clickable/#findComment-1281781 Share on other sites More sharing options...
ManiacDan Posted October 24, 2011 Share Posted October 24, 2011 I'm afraid you don't speak enough English (or javascript, for that matter) to receive much help on this forum. Your JS is still incorrect. Lines should end in semicolons. Quote Link to comment https://forums.phpfreaks.com/topic/249713-how-to-make-the-smiley-clickable/#findComment-1281784 Share on other sites More sharing options...
shebbycs Posted October 24, 2011 Author Share Posted October 24, 2011 <html> <head> </head> <body> <form action='registration.php' method='post'> Your message:<br><textarea name='message' cols='40' rows='2'></textarea><br> <a onClick=\"addSmiley('')\"><img src='smile.gif'></a> <a onClick=\"addSmiley('')\"><img src='blush.gif'></a> <a onClick=><img src='blush.gif'></a> <a onClick=\"addSmiley('')\"><img src='images/wink.gif'></a> <input type='submit' name='submit' value='Set Name'></form> <script type="text/javascript"> function addSmiley(a) { document.form.message.value + = a; document.form.message.focus(); } </script> <br> <br> </body> </html> thanks for notifying sir but still same not working any other wrong in this code? Quote Link to comment https://forums.phpfreaks.com/topic/249713-how-to-make-the-smiley-clickable/#findComment-1281785 Share on other sites More sharing options...
ManiacDan Posted October 24, 2011 Share Posted October 24, 2011 Almost all of this was wrong. Fixed version below. You will have to actually learn JavaScript/HTML to continue. Read that, please. Your syntax was incorrect, this was not valid HTML and was not valid JavaScript. <html> <head> <script type="text/javascript"> function addSmiley(a) { document.getElementById('message').value = document.getElementById('message').value + a; document.fgetElementById('message').focus(); } </script> </head> <body> <form action='registration.php' method='post'> Your message:<br><textarea id="message" name='message' cols='40' rows='2'></textarea><br> <a href="#" onClick="addSmiley(':-)')">:-)</a> <a href="#" onClick="addSmiley(';-)')">;-)</a> <a href="#" onClick="addSmiley(':-(')">:-(</a> <a href="#" onClick="addSmiley(':-P')">:-P</a> <input type='submit' name='submit' value='Set Name'></form> <br> <br> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/249713-how-to-make-the-smiley-clickable/#findComment-1281814 Share on other sites More sharing options...
shebbycs Posted October 25, 2011 Author Share Posted October 25, 2011 Sir thanks for your help for the code but i had figured it myself <html> <head> <script type="text/javascript"> function addsmiley(code) { var pretext = document.smile.message.value; this.code = code; document.smile.message.value = pretext + code; } function a() { var x = document.smile.message.value; if(x=="") { alert("Please insert an message!"); return false; } } </script> </head> <body> <form name="smile" method="post" action="registration.php" onSubmit="return a()" > Your message:<br><textarea name='message' cols='40' rows='2'></textarea><br> <img src="smile.gif" alt="" onClick="addsmiley('')" style="cursor:pointer;border:0" /> <img src="blush.gif" alt="" onClick="addsmiley('*blush*')" style="cursor:pointer;border:0" /> <input type='submit' name='submit' value='Set Name' ></form> <br> <br> </body> </html> and it can be run Quote Link to comment https://forums.phpfreaks.com/topic/249713-how-to-make-the-smiley-clickable/#findComment-1281978 Share on other sites More sharing options...
shebbycs Posted October 25, 2011 Author Share Posted October 25, 2011 Using that method how im can apply by clciking one smiley it will show many smiley same as like this Quote Link to comment https://forums.phpfreaks.com/topic/249713-how-to-make-the-smiley-clickable/#findComment-1281992 Share on other sites More sharing options...
shebbycs Posted October 28, 2011 Author Share Posted October 28, 2011 any reply from this image above? Quote Link to comment https://forums.phpfreaks.com/topic/249713-how-to-make-the-smiley-clickable/#findComment-1282897 Share on other sites More sharing options...
ManiacDan Posted October 28, 2011 Share Posted October 28, 2011 The sentence above that picture makes absolutely no sense. Please reword it. Quote Link to comment https://forums.phpfreaks.com/topic/249713-how-to-make-the-smiley-clickable/#findComment-1282995 Share on other sites More sharing options...
shebbycs Posted October 28, 2011 Author Share Posted October 28, 2011 The sentence above that picture makes absolutely no sense. Please reword it. ok sir im will rewrote and edit it Quote Link to comment https://forums.phpfreaks.com/topic/249713-how-to-make-the-smiley-clickable/#findComment-1283100 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.