Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-04-2007, 06:38 AM   PM User | #1
jukebox42
New to the CF scene

 
Join Date: Jan 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
jukebox42 is an unknown quantity at this point
Question Javascript: Inserting text into a textarea using lists

I know this question has been answered but not exactly in this fashion. I am trying to create a simple form edit function using my primitive phpbb skills. My issue is when using a list( <select> ) IE dosn't insert the text i want into the text area. the code I'm using is:

Javascript:(called by my header function)
<script type="text/javascript">
//add bbcode
function addbb(items) {
doc_content = document.form.content.value + items
document.form.content.value = doc_content
document.form.content.focus()
}
</script>

and used in:
<select >
<option onClick="javascript:addbb('[COLOR=GREY ]TEXT HERE[/COLOR]')"><font color='#CCCCCC'>grey</font></option>
<option onClick="javascript:addbb('[COLOR=RED ]TEXT HERE[/COLOR]')"><font color='#FF0000'>red</font></option>
<option onClick="javascript:addbb('[COLOR=GREEN ]TEXT HERE[/COLOR]')"><font color='#00FF00'>green</font></option>
<option onClick="javascript:addbb('[COLOR=BLUE ]TEXT HERE[/COLOR]')"><font color='#0000FF'>blue</font></option>
<option onClick="javascript:addbb('[COLOR=YELLOW ]TEXT HERE[/COLOR]')"><font color='#FFFF00'>yellow</font></option>
<option onClick="javascript:addbb('[COLOR=TEAL ]TEXT HERE[/COLOR]')"><font color='#00FFFF'>teal</font></option>
<option onClick="javascript:addbb('[COLOR=PURPLE ]TEXT HERE[/COLOR]')"><font color='#FF00FF'>purple</font></option>
</select>

I know the javascript works because i have a few buttons that call the same function but for some reason IE wont work with this. I works in firefox however I also need this to be IE compatible.

if anyone could help i would greatly appreciate it:confused:

Last edited by jukebox42; 01-04-2007 at 06:40 AM..
jukebox42 is offline   Reply With Quote
Old 01-04-2007, 08:31 AM   PM User | #2
Kor
Red Devil Mod


 
Kor's Avatar
 
Join Date: Apr 2003
Location: Bucharest, ROMANIA
Posts: 8,478
Thanks: 58
Thanked 379 Times in 375 Posts
Kor has a spectacular aura aboutKor has a spectacular aura about
You should use onchange handling the select control, not the onclick handling the option element. IE has a bug, does not allow onclick as a native option's event. I am not very sure what you have in mind, but maybe this will do the job:
Code:
<select onchange="this.form['content'].value+=this.value">
<option value="[COLOR=GREY ]TEXT HERE[/color]">grey</option>
<option value="[COLOR=Red ]TEXT HERE[/color]">red</option>
.....
</select>
__________________
KOR
Offshore programming
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
Kor is offline   Reply With Quote
Old 01-04-2007, 05:32 PM   PM User | #3
jukebox42
New to the CF scene

 
Join Date: Jan 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
jukebox42 is an unknown quantity at this point
this was exactly what i was looking for thanks.
jukebox42 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:22 PM.


Advertisement
Log in to turn off these ads.