...

View Full Version : adding an onclick to a select button ?



jeddi
01-27-2009, 02:10 PM
Hello,

I have these following 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'),'','');">

<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 ? :confused:

will appreciate any advice :)

angst
01-27-2009, 02:13 PM
try this:



<select name="x_size" onChange="wrapText(document.getElementById('TheTextArea'),'','');">

rangana
01-27-2009, 02:13 PM
Use onchange:


<select name="x_size" onchange="wrapText(document.getElementById('TheTextArea'),'','');">

jeddi
01-27-2009, 04:30 PM
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:


<select id="x_size" name="x_size" onChange="wrapText(document.getElementById('TheTextArea'),'','');">
<option value = '8' >8 &nbsp;&nbsp;</option>
<option value = '10' >10 &nbsp;&nbsp;</option>
etc etc

And this is the result:

http://www.devchoice.info/images/alert03.jpg

I was hoping for:

Any ideas ?

jcrypt
01-27-2009, 04:41 PM
<select id="x_size" name="x_size" onChange="wrapText(document.getElementById('TheTextArea'),'','');">

jeddi
01-27-2009, 05:39 PM
Yep,
Thats terrific!
thanks :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum