PC Review


Reply
Thread Tools Rate Thread

change dropdownlist selected index with javascript

 
 
Antonio
Guest
Posts: n/a
 
      9th Aug 2005
Hi, in my page's <body tag>'s "onload" javascript event I want to call
a javascript method that will change the selected index of a drop down
list. I want it to happen every time the page gets refreshed but not
do it with codebehind, it has to be javascript.

How do I do it?

 
Reply With Quote
 
 
 
 
Lucas Tam
Guest
Posts: n/a
 
      9th Aug 2005
"Antonio" <(E-Mail Removed)> wrote in news:1123594526.368603.223910
@z14g2000cwz.googlegroups.com:

> Hi, in my page's <body tag>'s "onload" javascript event I want to call
> a javascript method that will change the selected index of a drop down
> list. I want it to happen every time the page gets refreshed but not
> do it with codebehind, it has to be javascript.
>
> How do I do it?




document.getElementById('dropdownlistname').selectedIndex = indexNumber

You can get the dropdownlist name via the .NET ClientID property of each
control.

So you'll have to dynamically output the javascript via codebehind. Take
a look at the function Page.RegisterClientScriptBlock on an example of
including dynamically written javascript.

http://msdn.microsoft.com/library/de...l=/library/en-
us/cpref/html/frlrfSystemWebUIPageClassRegisterClientScriptBlockTopic.as
p


--
Lucas Tam ((E-Mail Removed))
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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
Clear selected value of Dropdownlist with Javascript Ian Microsoft ASP .NET 0 1st Feb 2010 10:10 AM
dropdownlist selected index remains zero. Harsha Microsoft ASP .NET 1 25th Nov 2009 08:30 AM
dropdownlist selected Index remains zero. Harsha Microsoft ASP .NET 1 25th Nov 2009 08:29 AM
Calling Javascript function on Gridview selected index change Sobin Thomas Microsoft ASP .NET 1 12th Aug 2008 10:58 AM
get the selected value of the asp:dropdownlist in javascript Thierry Microsoft ASP .NET 1 12th Dec 2003 02:50 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:21 PM.