From: http://spservices.codeplex.com/discussions/394723#post911479
Expost
Hi Marc. I've got a cascading drop down list with 20+ items in it. I am trying to get the displayed text of the drop down list that has been converted. I can't seem to obtain it using jQuery.
The code is as below.
<td class="WordCategory"><span dir="none"><span style="vertical-align:middle"><input name="ctl00$m$g_d3f2c715_3b7b_4866_a877_9fa4743d9ae8$ff10_1$ctl00$ctl01" type="text" value="class" id="ctl00_m_g_d3f2c715_3b7b_4866_a877_9fa4743d9ae8_ff10_1_ctl00_ctl01" class="ms-lookuptypeintextbox" onfocusout="CoreInvoke('HandleLoseFocus')" opt="_Select" title="ResolutionSubCategory" optHid="SPResolutionSubCategory_Hidden" onkeypress="CoreInvoke('HandleChar')" onkeydown="CoreInvoke('HandleKey')" match="" choices="class|1|cliff|2|cling|3|clink|4|clip|5|close|6|clot|7|club|8|clump|9|clung|10|cone|11|crab|12|craft|13|cram|14|cramp|15|crib|16|crime|17|crisp|18|crop|19|crust|20|cure|21|cute|22|" onchange="CoreInvoke('HandleChange')" /><img alt="Display lookup values" onclick="CoreInvoke('ShowDropdown','ctl00_m_g_d3f2c715_3b7b_4866_a877_9fa4743d9ae8_ff10_1_ctl00_ctl01');" src="/_layouts/images/dropdown.gif" style="border-width:0px;vertical-align:middle;" /></span><br/></span></td>
As you can see, the current selected item from the drop down list is "class" from the "value" attribute. I tried the following jQuery code below to show an alert but it doesn't work.
var test = $(".WordCategory :input").attr('text');
alert(test);
The above produces "undefined" from the alert.
var test = $(".WordCategory :input").val();
alert(test);
The above produces "1" from the alert.
var test = $(".WordCategory :input").text();
alert(test);
The above will produces the entire drop down list into the alert with a few lines.
Any idea how do I extract just the text being displayed in the drop down list Marc? Thank you for your time!
Expost
Hi Marc. I've got a cascading drop down list with 20+ items in it. I am trying to get the displayed text of the drop down list that has been converted. I can't seem to obtain it using jQuery.
The code is as below.
<td class="WordCategory"><span dir="none"><span style="vertical-align:middle"><input name="ctl00$m$g_d3f2c715_3b7b_4866_a877_9fa4743d9ae8$ff10_1$ctl00$ctl01" type="text" value="class" id="ctl00_m_g_d3f2c715_3b7b_4866_a877_9fa4743d9ae8_ff10_1_ctl00_ctl01" class="ms-lookuptypeintextbox" onfocusout="CoreInvoke('HandleLoseFocus')" opt="_Select" title="ResolutionSubCategory" optHid="SPResolutionSubCategory_Hidden" onkeypress="CoreInvoke('HandleChar')" onkeydown="CoreInvoke('HandleKey')" match="" choices="class|1|cliff|2|cling|3|clink|4|clip|5|close|6|clot|7|club|8|clump|9|clung|10|cone|11|crab|12|craft|13|cram|14|cramp|15|crib|16|crime|17|crisp|18|crop|19|crust|20|cure|21|cute|22|" onchange="CoreInvoke('HandleChange')" /><img alt="Display lookup values" onclick="CoreInvoke('ShowDropdown','ctl00_m_g_d3f2c715_3b7b_4866_a877_9fa4743d9ae8_ff10_1_ctl00_ctl01');" src="/_layouts/images/dropdown.gif" style="border-width:0px;vertical-align:middle;" /></span><br/></span></td>
As you can see, the current selected item from the drop down list is "class" from the "value" attribute. I tried the following jQuery code below to show an alert but it doesn't work.
var test = $(".WordCategory :input").attr('text');
alert(test);
The above produces "undefined" from the alert.
var test = $(".WordCategory :input").val();
alert(test);
The above produces "1" from the alert.
var test = $(".WordCategory :input").text();
alert(test);
The above will produces the entire drop down list into the alert with a few lines.
Any idea how do I extract just the text being displayed in the drop down list Marc? Thank you for your time!