Please login or register. Welcome to the Studio, guest!


Quick Links:


newBookmarkLockedFalling

Mithras

Mithras Avatar

****
Studio Member

600


July 2006
Hey, I'm working on this code that puts a drop-down box above the quick reply, with the smiley names in it, and when you click on the name, it adds the smiley to the quick reply. The only problem, is that you can't add any smilies after you type something in the box. I have no idea why it works before you type in it, because it works fine until then, even adding multiple smilies. If anyone has any ideas why this isn't working, please post.


<script type='text/javascript'>
<!--

// Smiles - [Smiley Name, UBBC Code] -- Do not edit unless you want to add smilies
var allSmilies = [
   ['Happy', ' :)'],
   ['Wink', ' ;)'],
   ['Cheesy.', ' :D'],
['Grin', ' ;D'],
   ['Angry', ' >:('],
   ['Sad', ' :('],
   ['Shocked', ' :o'],
   ['Cool', ' 8-)'],
['Confused', ' ???'],
   ['Rolling', ' ::)'],
   ['Tongue', ' :P'],
   ['Embarassed', ' :-['],
   ['Sealed', ' :-X'],
   ['Undecided', ' :-/'],
   ['Kiss', ' :-*'],
   ['Crying', " :'("]
];

function addSmiley() {
var ta = document.getElementsByTagName('textarea');
var currentHTML = ta[0].innerHTML;
var whichSmiley = document.smileyForm.smiley.selectedIndex;
currentHTML += allSmilies[whichSmiley][1];
ta[0].innerHTML = currentHTML;
}
if(location.href.match(/thread=/)) {
var tds = document.getElementsByTagName('TD')
for(a=0; a<tds.length; a++) {
if(tds[a].width=='100%' && tds[a+1].align=='right') {
var b = a
}
}
var quickReply = tds[b].innerHTML;
var smileyHTML = '<form name="smileyForm"><select name="smiley" onchange="javascript: addSmiley()">'

for(i=0; i<allSmilies.length; i++) {
smileyHTML += '<option value="' + allSmilies[i][1] + '">' + allSmilies[i][0] + '</option>';
}

smileyHTML += '</select></form><br/>';

tds[b].innerHTML = smileyHTML + '' + quickReply;
}
//-->
</script>




Support Rob Scuderi, the #1 Penguins Defender!

lucifer said:
"Behold: me! I have authority in this building."

Chris

Chris Avatar

******
Head Coder

19,519


June 2005
1. When messing with textareas, inputs, etc. use "value" not "innerHTML" ;)
2. Use this UBBC adder instead. Peter wrote it for PB originally, but its open source.

Mithras

Mithras Avatar

****
Studio Member

600


July 2006
Awesome! Thanks.

Edit: Omg, I just switched it from .innerHTML to .value, and it worked! I am going to go punch the wall for not thinking of this sooner.


Last Edit: Aug 18, 2006 1:24:52 GMT by Mithras


Support Rob Scuderi, the #1 Penguins Defender!

lucifer said:
"Behold: me! I have authority in this building."

Chris

Chris Avatar

******
Head Coder

19,519


June 2005
Form objects behave much differently then you'd think. :P I did the same thing back when I was a noob... and then I asked CJ for help. >.>


Last Edit: Aug 18, 2006 1:25:57 GMT by Chris

newBookmarkLockedFalling