Nexy Posted July 4, 2008 Share Posted July 4, 2008 Why Hello There! I seem to be having a problem with this little code: <script type="text/javascript"> function insertSmiley(smiley) { var area = document.getElementById("pmmsg"); area.setValue(area.getValue() + smiley); document.getElementById("pmmsg").focus(); } </script> <?php echo "<img src='board/images/smiles/happy.gif' alt='' onclick='insertSmiley(\"\")' /> <textarea id='pmmsg' name='pmmsg' rows='12' cols='45' tabindex='8'></textarea>"; ?> I have the last part in php because this is only part of the code. The problem is when I click the image, nothing happens. It doesn't add ": )" into the textarea. Any help would be appreciated. Thank You! Quote Link to comment Share on other sites More sharing options...
corbin Posted July 5, 2008 Share Posted July 5, 2008 Are you sure setValue and getValue are valid functions? Quote Link to comment Share on other sites More sharing options...
Nexy Posted July 5, 2008 Author Share Posted July 5, 2008 Sorry, I really had no idea what I was doing there. I just found those functions online and thought they were valid already. I looked more into this and I got this to work to some extent: <script type="text/javascript"> function insertText(text) { var elem = document.getElementById('pmmsg'); elem.innerHTML += text; document.getElementById('pmmsg').focus(); } </script> <?php echo "<img src=\"board/images/smiles/happy.gif\" alt=\"\" onclick=\"insertText(' ')\" /> <textarea id='pmmsg' name='pmmsg' rows='12' cols='45' tabindex='8'></textarea>"; ?> The only problem now is if you click the textarea or an input button, the smiles stop working. If you never click the textarea or the input buttons, then those smiles work just fine. I'm using Firefox if that makes any difference. Any ideas? Thank You Again! Quote Link to comment Share on other sites More sharing options...
Nexy Posted July 5, 2008 Author Share Posted July 5, 2008 NVM, I figured it out. Instead of innerHTML it had to be value. 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.