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 6 of 6
  1. #1
    Senior Coder
    Join Date
    May 2006
    Posts
    1,680
    Thanks
    28
    Thanked 4 Times in 4 Posts

    adding an onclick to a select button ?

    Hello,

    I have these following code:

    Code:
    <img class="sptr" src="/picts/separator.gif" width="6" height="20" alt="">
    <img class="imgbtn" src="/picts/in_image.gif" width="21" height="20" alt="" onClick="wrapText(document.getElementById('TheTextArea'),'[img]','[/img]');">
    
    <span class="select">Size: 
     <select name="x_size">
      <option value = '8' >8 &nbsp;&nbsp;</option>
      <option value = '10' >10 &nbsp;&nbsp;</option>
     <option value = '12' selected= "selected" >12 &nbsp;&nbsp;</option>
     <option value = '14' >14 &nbsp;&nbsp;</option>
     <option value = '16' >16 &nbsp;&nbsp;</option>
     <option value = '18' >18 &nbsp;&nbsp;</option>
     <option value = '20' >20 &nbsp;&nbsp;</option>
     <option value = '22' >22 &nbsp;&nbsp;</option>
     <option value = '24' >24 &nbsp;&nbsp;</option>
     <option value = '26' >26 &nbsp;&nbsp;</option>
     <option value = '28' >28 &nbsp;&nbsp;</option>
     <option value = '30' >30 &nbsp;&nbsp;</option>
     <option value = '32' >32 &nbsp;&nbsp;</option>
     <option value = '34' >34 &nbsp;&nbsp;</option>
     <option value = '36' >36 &nbsp;&nbsp;</option>
     <option value = '38' >38 &nbsp;&nbsp;</option>
    </select></span>
    As you can see the image has an onclick associated with it.

    I want to do a similar thing with the selection of the font-size.

    As the action needs to occur after the client has selected the size, probably I will need "on buttun up" ( or is it onRelease ? )

    Also which line should the code go on ?
    this one <select name="x_size"> ?
    or on all the option statements ?

    will appreciate any advice

  • #2
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts
    try this:

    PHP Code:
    <select name="x_size" onChange="wrapText(document.getElementById('TheTextArea'),'[img]','[/img]');"

  • #3
    Senior Coder rangana's Avatar
    Join Date
    Feb 2008
    Location
    Cebu City, Philippines
    Posts
    1,752
    Thanks
    65
    Thanked 372 Times in 365 Posts
    Use onchange:
    Code:
    <select name="x_size" onchange="wrapText(document.getElementById('TheTextArea'),'[img]','[/img]');">
    Learn how to javascript at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph

  • #4
    Senior Coder
    Join Date
    May 2006
    Posts
    1,680
    Thanks
    28
    Thanked 4 Times in 4 Posts
    Thanks for help,

    I have applied your suggestion to my font-size select button
    and tried to take it a bit further by including the selected value.

    Here is what I have coded:

    Code:
    <select id="x_size" name="x_size" onChange="wrapText(document.getElementById('TheTextArea'),'[sz=document.getElementById(\'x_size\']','[/sz]');">
    <option value = '8' >8 &nbsp;&nbsp;</option>
    <option value = '10' >10 &nbsp;&nbsp;</option>
    etc etc
    And this is the result:



    I was hoping for:[sz=10] [/sz]

    Any ideas ?

  • #5
    New Coder
    Join Date
    Jan 2009
    Posts
    42
    Thanks
    2
    Thanked 6 Times in 6 Posts
    Code:
    <select id="x_size" name="x_size" onChange="wrapText(document.getElementById('TheTextArea'),'[sz='+this.value+']','[/sz]');">

  • #6
    Senior Coder
    Join Date
    May 2006
    Posts
    1,680
    Thanks
    28
    Thanked 4 Times in 4 Posts
    Yep,
    Thats terrific!
    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
    •