473,467 Members | 1,291 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

programmatically select an option in dropdown

13 New Member
Hi friends,

I have an (VBA) application which programatically fills the options in a web page.
I have an dropdown menu whose options are selected during run-time by using a function.Is there anyway by which I can select the option in the dropdown menu programatically?
If the dropdown menu had its options explicitily mentioned (like <option value="1">1</option>...) I could have used document.form.objectname.selectedindex=n
But here all I have is a function to generate the values in the dropdown menu.
<select name="name" id= "">
print_month_element_drop_down_menu(1, 12, 2, ' ');
</select>
Is there a wayout to select the desired value programmatically?

(I am temporarily using the sendkeys method,but it isnt that gr8 a solution...:-))

Regards,
Balu435
Feb 26 '07 #1
5 3553
dmjpro
2,476 Top Contributor
i think u r using VB ...

so u better to look for VB forum
Feb 26 '07 #2
dorinbogdan
839 Recognized Expert Contributor
To get a reference to the selected item, you can use this method:
[HTML]var dropdown = document.getElementById("dropdownId");
var item = dropdown[dropdown.selectedIndex];
[/HTML]
Feb 26 '07 #3
acoder
16,027 Recognized Expert Moderator MVP
Also, don't forget to set the id for your dropdown. It is currently empty.
Feb 27 '07 #4
balu435
13 New Member
Also, don't forget to set the id for your dropdown. It is currently empty.
hi,
I am writing the code in VBA and the dropdown menu is in an external web page..
I cant fiddle with the HTML code there...
I have submitted the query in VB forum as well..
Thanx for your help..
Balu435
Mar 2 '07 #5
balu435
13 New Member
hi,
I am writing the code in VBA and the dropdown menu is in an external web page..
I cant fiddle with the HTML code there...
I have submitted the query in VB forum as well..
Thanx for your help..
Balu435
Hi..
Its working now..
I gave the code as document.form.object.selectedindex.=n
where n is the index of the required value..
I dont understand if it can get so simple..anyway its working..:-)
Mar 5 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Oskar Wild | last post by:
Hello, how do I code it to display a select (pulldown) box only if the user has selected a certain option in another pulldown box? <select name=country> <OPTION value="France" SELECTED>France...
6
by: passion_to_be_free | last post by:
This is probably simple, but I can't seem to find it anywhere. I have have some values stored in javascript variables. I have a <select> dropdown list whose options correspond to these values. I...
7
by: pk | last post by:
Here is my code, and it's not working. Please help me get through this. I've read every single tutorial and you may even see remnants of some of their variables in my code. I don't know if I'm...
2
by: Monty | last post by:
I use a SELECT dropdown as the nav interface for jumping to a chosen page number. When I setup up the SELECT element on the page, I want to show the user the current page number they are on, so, I...
4
by: =?Utf-8?B?c2lMdmVy?= | last post by:
Hhi, I'm working on an asp .net project that have small side panel which 'disallow' long SELECT/dropdown list.. So i could not force them to a certain that shows my longest option, which now...
3
by: balu435 | last post by:
Hi friends, I have an (VBA) application which programatically fills the values in a web page. In the web page there is a dropdown menu whose options are selected during run-time by using a...
7
by: fran7 | last post by:
Hi, I am having trouble with this dropdown. With it I am passing an id to the next page but displaying a description in the dropdown. Trouble is it displays a description for every postid so I am...
1
by: RichardR | last post by:
I have a webpage which has a table that contains a column with several drop down boxes (<SELECT>). The contents of the drop down boxes are dynamically populated so I have no idea what the actually...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.