Determining a value of a selected option in a select tag:

document.formname.selectname.options[
document.formname.selectname.selectedIndex].value

Determining the text of a selected option in a select tag:

document.formname.selectname.options[
document.formname.selectname.selectedIndex].text

Inserting a new option into a select tag:
var myformelm = document.formname.selectname;
var newoption = new Option();
newoption.value = 'my new value';
newoption.text = 'my new text';
myformelm.options[myformelm.options.length] = newoption

On 3/21/07 9:17 AM, "Rob Wilkerson" <[EMAIL PROTECTED]> wrote:

> Options within selects don't have an onclick event.  Use the onchange
> event of the select, instead, and detect the selected value.  I'm new
> to jQuery, but you can't do this in straight JavaScript (unless I've
> missed the memo - which is possible), so I suspect you may not be able
> to do it in jQuery.
> 
> On 3/21/07, Aljosa Mohorovic <[EMAIL PROTECTED]> wrote:
>> i have a "DIV.selection" tag and inside SELECT with OPTION tags.
>> using jquery i can find and manipulate options with
>> $('div.selection').find("option").each and similar but i can't bind
>> events for option onclick events in IE7 (haven't looked IE6, firefox
>> works).
>> 
>> so i'm looking for a way to manipulate option tags in select box and
>> catch events.
>> is there any way to do this for any browser? simple examples appreciated.
>> 
>> Aljosa
>> 
>> _______________________________________________
>> jQuery mailing list
>> discuss@jquery.com
>> http://jquery.com/discuss/
>> 
> 
> _______________________________________________
> jQuery mailing list
> discuss@jquery.com
> http://jquery.com/discuss/


_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to