473,761 Members | 10,365 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Programmaticall y Select Option

J1C
If I only know the value of an option is a select list, is it possible
to programmaticall y select that option?

I would be returning the value from a server-side script ...

Jul 23 '05 #1
4 1973
Lee
J1C said:

If I only know the value of an option is a select list, is it possible
to programmaticall y select that option?

I would be returning the value from a server-side script ...


How are you returning it? If you're sending the whole page,
just give that option tag the SELECTED attribute.

Jul 23 '05 #2
J1C wrote:
If I only know the value of an option is a select list, is it possible
to programmaticall y select that option?

I would be returning the value from a server-side script ...


Loop through the options in the select. When you find one with the
required value, set its selected property to true.
function selectOpt( f, s, v ){
var opts = document.forms[f].elements[s].options;
var o, i = opts.length;
while ( ( o == opts[--i] ) ) {
if ( o.value == v ) {
o.selected = true;
return;
}
}
}

If it's a multiple select, drop the return.

--
Fred
Jul 23 '05 #3
Fred Oz wrote:
[...]

function selectOpt( f, s, v ){
var opts = document.forms[f].elements[s].options;
var o, i = opts.length;
while ( ( o == opts[--i] ) ) {


Agghh...

while ( ( o = opts[--i] ) ) {
...

[...]

--
Fred
Jul 23 '05 #4
J1C
thanks all!

Jul 23 '05 #5

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

Similar topics

0
467
by: Keith | last post by:
Is it possible to modify the file properties of a file programmatically? For example, every file, when you right click has a properties option, then from that you can select the summary tab and from that set the Title, Author and Subject. I use c# and VB but can't find a way how to set these programmatically. Any one have any idea how to do this? Thanks - Keith.
2
4259
by: Robbie | last post by:
Hi, I want to programatically fire an event. I have it working in IE, but Netscape won't work. What is the Netscape equivalent to, or a workaround for: document.myForm.myField.onchange(); I've read many posts, but none seem to answer my question. Anyway, my example follows.
8
16669
by: deko | last post by:
I'm trying to find a way to set form/control properties programmatically. In a nut shell: 1. Open a database 2. Open a form in design view 3. Do something like this: For Each prp In frm.Properties If prp.Name = rst!PropName Then prp = rst!ChangeTo
2
4842
by: Charles | last post by:
Ok, so I'm creating a form on the fly. I can create the option group, I can create the checkboxes, but I can't figure out how to bind them to the option group I'm creating them within. I was hoping the fact that creating them inside the option group would cause it to automatically bind, but no go. As it stands now I create the option group and bind it to a field in a table, then create the checkboxes inside the option group. After that,...
2
4553
by: Nicole | last post by:
I am creating template columns programmatically. I have read the msdn article on this and I'm so close. Article: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/vbtchcreatingwebservercontroltemplatesprogrammatically.asp I have narrowed down the problem comes in when the _DataBinding handler is called and the literal text is being assigned, but I can't figure out beyond that. The main problem is that...
32
3692
by: deko | last post by:
I have a popup form with a textbox that is bound to a memo field. I've been warned about memo fields so I'm wondering if I should use this code. Is there any risk with changing the form's RecordSource like this? Am I asking for trouble doing this with a memo field? Thanks in advance. Private Sub cmdNextNote_Click() Dim lngNid As Long If Me.Dirty Then DoCmd.RunCommand acCmdSaveRecord
8
3761
by: William Foster | last post by:
Good evening all, I am creating a program with the ability to select an option from a ComboBox which will then create a secondary list of options in a CheckedListBox. Previously when I have needed to create multiples of this type of user option I have simply hard coded three or four set options for the user. However, I would like to have the option for the user to have as many options available as they like. In order to do this I...
5
3592
by: balu435 | last post by:
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...
1
3004
by: rvelosoo | last post by:
Hi, I'm having trouble selecting an option in html, i.e. i change the code, but the change is not reflected in the browser. Example, i have <select> <option>A <option selected>B </selected>
0
9531
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9345
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10115
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9957
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9905
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9775
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8780
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7332
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
3
2752
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.