Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > DropDownList SelectedItem Javascript

Reply
Thread Tools

DropDownList SelectedItem Javascript

 
 
Alper ÖZGÜR
Guest
Posts: n/a
 
      03-06-2006
Hi;
I can read the selectedvalue of dropdownlist by javascript using
this.value...
How can i get the selectedItem.text by javascript?


 
Reply With Quote
 
 
 
 
S. Justin Gengo [MCP]
Guest
Posts: n/a
 
      03-06-2006
Alper,

this.options[this.selectedIndex].value

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Alper ÖZGÜR" <> wrote in message
news:...
> Hi;
> I can read the selectedvalue of dropdownlist by javascript using
> this.value...
> How can i get the selectedItem.text by javascript?
>
>



 
Reply With Quote
 
 
 
 
Alper ÖZGÜR
Guest
Posts: n/a
 
      03-06-2006
It returns the SelectedValue... Not SelectedText.....

"S. Justin Gengo [MCP]" <justin@[no_spam_please]aboutfortunate.com>, haber
iletisinde şunları yazdı:...
> Alper,
>
> this.options[this.selectedIndex].value
>
> --
> Sincerely,
>
> S. Justin Gengo, MCP
> Web Developer / Programmer
>
> www.aboutfortunate.com
>
> "Out of chaos comes order."
> Nietzsche
> "Alper ÖZGÜR" <> wrote in message
> news:...
>> Hi;
>> I can read the selectedvalue of dropdownlist by javascript using
>> this.value...
>> How can i get the selectedItem.text by javascript?
>>
>>

>
>



 
Reply With Quote
 
S. Justin Gengo [MCP]
Guest
Posts: n/a
 
      03-06-2006
Alper,

Sorry about that. I forgot to switch it from some of my code I copy and
pasted. It's pretty simple really. Just switch value to text.

this.options[this.selectedIndex].text

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Alper ÖZGÜR" <> wrote in message
news:...
> It returns the SelectedValue... Not SelectedText.....
>
> "S. Justin Gengo [MCP]" <justin@[no_spam_please]aboutfortunate.com>, haber
> iletisinde şunları yazdı:...
>> Alper,
>>
>> this.options[this.selectedIndex].value
>>
>> --
>> Sincerely,
>>
>> S. Justin Gengo, MCP
>> Web Developer / Programmer
>>
>> www.aboutfortunate.com
>>
>> "Out of chaos comes order."
>> Nietzsche
>> "Alper ÖZGÜR" <> wrote in message
>> news:...
>>> Hi;
>>> I can read the selectedvalue of dropdownlist by javascript using
>>> this.value...
>>> How can i get the selectedItem.text by javascript?
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
BigCJ29 BigCJ29 is offline
Junior Member
Join Date: Jul 2008
Posts: 1
 
      07-03-2008
Hi.. I want to know a way to write a text in a textbox and find the item in a dropdownlist and put it in the top of the list? thanks...
 
Reply With Quote
 
arnabb4u arnabb4u is offline
Junior Member
Join Date: Dec 2008
Posts: 1
 
      12-18-2008
I have just used this method in one of my .net project. u just add this method in ur .js file and call this from ur aspx page.

function SearchItem(textbox, dropdown, chk)
{
if(chk)
{
for(var i=0; i<=dropdown.length; i++)
{
if(textbox.value == dropdown[i].value)
{
dropdown[i].selected = true;
break;
}
}
}
else
textbox.value = dropdown.value;
}

in controls page add this property in ur aspx page:
<asp:TextBox ID="txt" runat="server" MaxLength="20" OnBlur="javascript:SearchItem(<%=txt.ClientID %>,<%=ddl.ClientID %>,true);"></asp:TextBox>
<aspropDownList ID="ddl" runat="server" onchange="javascript:SearchItem(<%=txt.ClientID %>,<%=ddl.ClientID %>);" />
 
Reply With Quote
 
witnes witnes is offline
Junior Member
Join Date: Mar 2011
Location: Ukraine, Kiev
Posts: 1
 
      03-26-2011
Html.DropDownList("selItemsPerPage1", Model.Items, new
{
onchange = "alert($('#selItemsPerPage1 option:selected').val());"
}
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem assigning selectedItem.Value to a dropdownlist filled with OnItemDataBound Antonio D'Ottavio ASP .Net 1 09-19-2005 09:41 AM
DropDownList SelectedItem Problem Ivan ASP .Net 4 11-25-2003 03:14 PM
Help Me~~My DropDownList Can not get the"BigClassList.SelectedItem.Text" there is an error: System.NullReferenceException huobazi ASP .Net 0 07-01-2003 10:38 PM
Re: Dropdownlist and SelectedItem in ASP.Net Jos Branders ASP .Net 6 06-25-2003 08:15 PM
Re: Dropdownlist and SelectedItem in ASP.Net Marina ASP .Net 0 06-25-2003 01:40 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57