Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/249713-how-to-make-the-smiley-clickable/
Share on other sites

<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

<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?

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>

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.