Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jan 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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.

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    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
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #3
    New to the CF scene
    Join Date
    Jan 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    this was exactly what i was looking for thanks.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •