473,499 Members | 1,948 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="cmbDepartment" id="cmbDepartment" style="width:120px">
<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 2382
mrhoo
428 Contributor
<select name="cmbDepartment" id="cmbDepartment" style="width:120px">
<option >winding</option>
<option>Testing</option>
</select>
var strDepta=document.getElementById('cmbDepartment');
var strDept=strDepta.options[strDepta.selectedIndex].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=strDepta.options[strDepta.selectedIndex].text

If you want anything uploaded to a server, be sure to set value attributes on your options-
<option value="0" selected= "selected">Select</option>
<option value="1">winding</option>
<option value="2">Testing</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
12064
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...
7
23519
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...
3
3013
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...
16
1762
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...
0
895
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...
2
6165
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...
4
4600
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...
6
4880
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...
4
6640
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...
1
4205
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...
0
7012
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...
0
7225
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
6901
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
7392
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
5479
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
3105
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...
0
3101
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1429
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 ...
0
307
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...

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.