473,320 Members | 2,027 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

change dropdownlist selected index with javascript

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?

Nov 19 '05 #1
1 16526
"Antonio" <bl*****@yahoo.com> 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').select edIndex = 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/frlrfSystemWebUIPageClassRegisterClientScriptBlock Topic.as
p
--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Scott Lee | last post by:
I am displaying an ASP.Net generated form in a popup opened with window.showModalDialog. The form contains DropDownList controls. The first ddl is populated via databinding to a datatable, has...
6
by: Julius Fenata | last post by:
Dear all, I have created client-side scripting to trigger event onChange from code-behind, like this: DropDownList1.Attributes = "GenerateArticleID()"; At the script on Windows Form, I...
4
by: wolfgang wagner | last post by:
hi all! after successfully integrating a dropdownlist in my datagrid i have another problem: i cannot set the selected index of the dropdownlistbox. here is my code: hardware.aspx...
1
by: Paul L | last post by:
Hi, I have an issue with the OnSelectedIndexChanged event not firing for a DropDownList control which is in the ItemTemplate of a DataList. I have made an exact copy of the DropDownList control,...
2
by: Radu | last post by:
Hi, I have a "select" control named "cboSelectScorecardType", defined as <select id="cboSelectScorecardType" size="1" runat="server"> </select> which shows a list of files on my drive. It...
4
by: rn5a | last post by:
I am binding a DropDownList with records existing in a database table. I want to add an extra item *SELECT COMPANY* at index 0 so that by default, it gets selected. This is how I tried it but the...
1
by: MaryamSh | last post by:
Hi, I am creating a Dynamic Search in my application. I create a user control and in Page_load event I create a dynamic dropdownlist and 2 dynamic button (Add,Remove) By pressing Add button...
0
by: MaryamSh | last post by:
Create Dynamic Dropdownlist Controls and related event -------------------------------------------------------------------------------- Hi, I am creating a Dynamic Search in my application. I...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.