Try this: $('#iNodeID').change( function() { if ( this.selectedIndex > -1 ) $('#sLinkText').val( this.options[ this.selectedIndex ].text ); });
Karl Rudd On 12/6/06, Bruce MacKay <[EMAIL PROTECTED]> wrote: > > Hello again, > > I've taken one step closer to fixing this problem: > > $('#iNodeID').change(function(){$("#sLinkText").val($("#iNodeID").attr("value"))}); > > returns the value of the selected option, but I still don't know how to get > the text between the option tags; .attr("option") doesn't return the text. > > While I could just append the text to the value attribute and then strip it > serverside before processing the value, I'm reluctant to do that because > some of the option strings are quite long and there are many options - I > don't want to add unnecessary weight to the page. > > What am I still missing here? What is my next option? > > Thanks, > > Bruce > > > At 09:16 a.m. 6/12/2006, you wrote: > > Hi folks, > > I'd appreciate some help with a form element task I wish to achieve. > > I have a form containing three elements (2 text and 1 select). > [sNewNodeTitle] > [iNodeID] <--- select > [sLinkText] > > For reasons that aren't important here, the user will either enter > something into sNewNodeTitle or select an existing item from the iNodeID > dropdown list. What I want to do is have either the entered text or the > text between the iNodeID select tags to be replicated into sLinkText. > > I've achieved the latter with > $('#sNewNodeTitle').keyup(function(){if(this.value.length>0) > $('#sLinkText').val(this.value);}); > > but I don't know how to get the required info from the select element. I > don't want the value of the selected select element (it will be an integer) > - I need the text. > > Can someone please provide me with some direction here. > > Thanks, > > Bruce > > > > > _______________________________________________ > 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/