473,394 Members | 1,765 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,394 software developers and data experts.

get the selected value of the asp:dropdownlist in javascript

Hi,

Is it possible to get the value of an asp:dropdownlist in javascript. I need
to get that value to assign it to a hyperlink.

This does not work:
document.FormEditCustomer.DDListVatCountry.selecte dIndex

<script language="javascript">
function GetVatPopup()
{
VATCheck_window=window.open('VATCheck.aspx?VATNumb er=' +
document.FormEditCustomer.TBVatNumber.value + '&VATCountry?' +
document.FormEditCustomer.DDListVatCountry.selecte dIndex + '',
'VATCheck');VATCheck_window.focus()
}
</script>
Thanks,
Thierry

Nov 18 '05 #1
1 11511
Thierry,

It renders as an HTML select element, so all the properties of the select
element are available on the client side. It does have a value property,
but this doesn't work reliably in all browsers. Using the option
represented by the selected index is a better general solution. e.g.:

var countrySelect = document.FormEditCustomer.DDListVatCountry;
if (countrySelect.selectedIndex > -1)
{
VATCheck_window = window.open('VATCheck.aspx?VATNumber=' +
document.FormEditCustomer.TBVatNumber.value + '&VATCountry?' +
countrySelect.options[countrySelect.selectedIndex].value,
'VATCheck');
VATCheck_window.focus();
}

If the VATCountry is represented in the display text of the option rather
than its value attribute, use the option's text property instead of its
value property.

HTH,
Nicole
"Thierry" <Th*****@nospam.com> wrote in message
news:y8********************@phobos.telenet-ops.be...
Hi,

Is it possible to get the value of an asp:dropdownlist in javascript. I need to get that value to assign it to a hyperlink.

This does not work:
document.FormEditCustomer.DDListVatCountry.selecte dIndex

<script language="javascript">
function GetVatPopup()
{
VATCheck_window=window.open('VATCheck.aspx?VATNumb er=' +
document.FormEditCustomer.TBVatNumber.value + '&VATCountry?' +
document.FormEditCustomer.DDListVatCountry.selecte dIndex + '',
'VATCheck');VATCheck_window.focus()
}
</script>
Thanks,
Thierry

Nov 18 '05 #2

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

Similar topics

0
by: C | last post by:
Hi, I have a drop down on my aspx as below. In between my opening and closing tags I render out the Items by populating a variable with the items. <asp:DropDownList id="selProf"...
5
by: John Davis | last post by:
When I create new documents in Dreamweaver, there are several choices for ASP creation: ASP JavaScript: run at client side?? ASP VBScript: run at server side?? ASP.NET C# ASP.NET VB I don't...
2
by: fad | last post by:
How can I create a database access using asp+javascript withen the code?Is there (createdatabase)?If yes how can we use it? thanks for all -- fad...
1
by: Shapper | last post by:
Hello, I have na Asp:DropDownList 2 things are not working in Firefox: CSS and Width. It works fine in Internet Explorer. How to solve this? Thanks,
0
by: Barb | last post by:
How can I limit the number of items that show up in a dropdown list at one time? I have a list of states, and because my dropdown list is near the bottom of the page, it becomes a drop-up list. ...
4
by: zfarooq01 | last post by:
Asp Javascript language paging larger database record sets i am firmiliar with asp javascript and not asp VB. i can display the results ok, but if i return 100 records from my table i would...
0
by: den 2005 | last post by:
Hi everybody, I created a Gridview with a TemplateField and there is Label control in ItemTemplate and a DropdownList control in EditItemTemplate, I was to displayed them ok when I click the...
3
by: =?Utf-8?B?T2xkQnV0U3RpbGxMZWFybmluZw==?= | last post by:
If I want to hang javascript off of an asp:DropDownList control, how would I do this? There does not seem to be a "onchange" event so do I have to use an HTML control to do this?
6
by: uicouic | last post by:
Hi all. I need help about this particular aspect. In a webform I have an <asp:textbox> (txtName) and <asp:DropDownList> (lstSchool) with 2 values inside. I have typed in a value for the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
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
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...

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.