473,626 Members | 3,093 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

i cant get combobox value in IE.

nirmalsingh
218 New Member
hi all,
[HTML]
<select name="cmbDepart ment" id="cmbDepartme nt" style="width:12 0px">
<option >winding</option>
<option>Testing </option>
</select>
[/HTML]
javascript
Expand|Select|Wrap|Line Numbers
  1. var strDepta=document.getElementById('cmbDepartment');
  2. var strDept=strDepta.options[strDepta.selectedIndex].value;
  3. alert(strDept);
  4.  
An empty alert is displayed in IE, but works fine in FF. what will be the problem? thanx in advance.
Jun 9 '07 #1
1 2393
mrhoo
428 Contributor
<select name="cmbDepart ment" id="cmbDepartme nt" style="width:12 0px">
<option >winding</option>
<option>Testing </option>
</select>
var strDepta=docume nt.getElementBy Id('cmbDepartme nt');
var strDept=strDept a.options[strDepta.select edIndex].value;
Firefox will return the text if there is no value, but that's browser dependent, and only seems to apply to options.

if you want the text of an option you should be explicit, for IE and others-

var strDept=strDept a.options[strDepta.select edIndex].text

If you want anything uploaded to a server, be sure to set value attributes on your options-
<option value="0" selected= "selected">Sele ct</option>
<option value="1">windi ng</option>
<option value="2">Testi ng</option>

Then you can find the value of an option in any browser with .value.
Jun 10 '07 #2

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

Similar topics

8
12084
by: Zlatko Matiæ | last post by:
There is a form (single form) and a combobox. I want that current record of the form is adjusted according to selected value in the combobox. Cuurrent record should be the same as the value in the combobox. What is the solution? Thank you in advance.
7
23525
by: NCrum | last post by:
I want to set the Default value of a Combobox for any changeable record and have got this working but it is totaly unsatisfactory see the code below I loop through the items in the Combo looking for a match between cVal and the selectedValue then stop when I do have a match the obvious problem is that each iteration fires the selectedIndexChanged but also for a large list this will slow everything down. There must be a better way int...
3
3023
by: PeterZ | last post by:
G'day, After doing much searching and pinching bits of ideas from here there and everywhere I came up with a fairly 'clean' solution of including a comboBox into a dataGrid column. You can download a fully working C# sample with the Northwind.mdb here: www.insightgis.com.au/web/stuff/DataGridCombo.zip
16
1772
by: Mike Fellows | last post by:
when i load my windows form i populate a combobox i use the code below Dim conn As New System.Data.SqlClient.SqlConnection(strConn) Dim sql As String = "AllLenders" Dim da As New System.Data.SqlClient.SqlDataAdapter(sql, conn) Dim ds As New DataSet() da.Fill(ds) ComboBox1.DataSource = ds.Tables(0) ComboBox1.DisplayMember = "Lender" da.Dispose()
0
899
by: Patricia Kline | last post by:
I am setting the datasource of a combobox to a arraylist that has two members (value and display). When I want to get the value of the combobox, there are no problems. However, when I try to set the selectedvalue to a value that I know for a fact is in there, using this code: cboAuthor.SelectedValue = intOldAuthor nothing happens. If I do a for loop, setting the selectedindex and a if statement, with the following code:
2
6191
by: Don | last post by:
I've looked high and low for some code that will allow me to have a combobox with a flat borderstyle. I found a few examples, but nothing that was really usable for me. I had the following criteria that I wanted to meet, but nothing did: - No reliance on a separate library - No unmanaged code - Easy subclassing of System.Windows.Forms.Combobox (i.e. no custom control monstrosity) - No extra funky features that I didn't need
4
4609
by: jon f kaminsky | last post by:
Hi- I've seen this problem discussed a jillion times but I cannot seem to implement any advice that makes it work. I am porting a large project from VB6 to .NET. The issue is using the combo box bound to a table as a lookup, drawing values from another table to populate the available selections. This all worked fine in VB6. I have distilled the problem down to a simple form drawing data from the Northwind database for a representative...
6
4905
by: Matt | last post by:
I'm not entirely sure how to describe this issue. I have a number of ComboBoxes in my application which have their text properties bound to a field in a data set. The items loaded in the ComboBox are not data bound (they just use the built in collection property of the ComboBox), and they are all set to use the DropDownList style. When moving from record to record via a BindingNavigator or a DataGridView (in master/detail format), the text...
4
6660
by: Jerad Rose | last post by:
I'm baffled by this -- is there not a typed object used for ComboBox Items? Best I can tell, all of the methods for ComboBox that accept an Item are of type Object. Why in the world is a common/standard .NET control accepting an Object as a parameter type? In Web Forms, there is a ListItem object that can be passed in to add/retrieve objects from a DropDownItems collection. I searched Google groups, and all the solutions I'm finding...
1
4229
by: Andrus | last post by:
I need to enter null value from combobox to business object property. My combobox datasource does not contain ValueMember with null value. So I tried to create combobox which stores null to bound object when text is deleted. However bound object contains old value in this case. To reproduce: 1. Run code
0
8259
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
8637
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...
0
8502
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...
1
6119
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...
0
5571
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4090
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4195
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1805
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1504
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.