Hi group,
I am trying to change the selection of an ASP Dropdownlist just like
"Orange" is selected here: http://www.w3schools.com/js/tryit.as...ption_selected
The following works fine on IE:
document.getEle mentById('dropd own').options.s elected = 0 //
selects the first option
But, I need this to work on other browsers as well.
I started by adding the "id" attribute to the ASP:ListItem in order to
access them by their ID (like in the W3C example above), but it does
not get rendered in the produced HTML page.
How could I achieve this in a crossbrowser, standard way?
Thanks. 11 4459
On May 26, 7:04 am, harold.gime...@ gmail.com wrote:
Hi group,
I am trying to change the selection of an ASP Dropdownlist just like
"Orange" is selected here:
http://www.w3schools.com/js/tryit.as...ption_selected
The following works fine on IE:
document.getEle mentById('dropd own').options.s elected = 0 //
selects the first option
But, I need this to work on other browsers as well.
I started by adding the "id" attribute to the ASP:ListItem in order to
access them by their ID (like in the W3C example above), but it does
not get rendered in the produced HTML page.
How could I achieve this in a crossbrowser, standard way?
Thanks.
Hi,
Please check this link ... in this blog post i have dropped few lines
which might help you http://munnacs.blogspot.com/2007/05/...ml-select.html
Thanks
Masudur
On May 26, 12:41 am, Masudur <munn...@gmail. comwrote:
On May 26, 7:04 am, harold.gime...@ gmail.com wrote:
Hi group,
I am trying to change the selection of an ASP Dropdownlist just like
"Orange" is selected here:
http://www.w3schools.com/js/tryit.as...ption_selected
The following works fine on IE:
document.getEle mentById('dropd own').options.s elected = 0 //
selects the first option
But, I need this to work on other browsers as well.
I started by adding the "id" attribute to the ASP:ListItem in order to
access them by their ID (like in the W3C example above), but it does
not get rendered in the produced HTML page.
How could I achieve this in a crossbrowser, standard way?
Thanks.
Hi,
Please check this link ... in this blog post i have dropped few lines
which might help youhttp://munnacs.blogspo t.com/2007/05/select-items-of-html-select.html
Thanks
Masudur
Thanks for your reply.
The other thing I tried from your blog did not really work out either:
document.getEle mentById('dropd own').value = "1";
or
document.getEle mentById('dropd own').options[1].selected = true;
These two work on IE7 but not Firefox.
I guess the bottom line is: is there a way to assign id s to the list
elements in order for me to access them with getElementById( 'option1')
on Firefox? Maybe there is a way on the code behind to add this
attribute...
I am using .NET Framework 1.1...
Thanks again.
On May 26, 6:20 pm, harold.gime...@ gmail.com wrote:
document.getEle mentById('dropd own').options.s elected = 0 //
selects the first option
document.getEle mentById('dropd own').selectedI ndex = 0
should help.
On May 26, 1:50 pm, Alexey Smirnov <alexey.smir... @gmail.comwrote :
On May 26, 6:20 pm, harold.gime...@ gmail.com wrote:
document.getEle mentById('dropd own').options.s elected = 0 //
selects the first option
document.getEle mentById('dropd own').selectedI ndex = 0
should help.
Unfortunately it didn't work on Firefox either. Also works fine on IE.
Thanks, though...
On May 27, 9:39 pm, harold.gime...@ gmail.com wrote:
On May 26, 1:50 pm, Alexey Smirnov <alexey.smir... @gmail.comwrote :
On May 26, 6:20 pm, harold.gime...@ gmail.com wrote:
document.getEle mentById('dropd own').options.s elected = 0 //
selects the first option
document.getEle mentById('dropd own').selectedI ndex = 0
should help.
Unfortunately it didn't work on Firefox either. Also works fine on IE.
Thanks, though...
It does work. I've tested in FF 2.0
Can you give me the full code of your script, please?
On May 27, 3:54 pm, Alexey Smirnov <alexey.smir... @gmail.comwrote :
On May 27, 9:39 pm, harold.gime...@ gmail.com wrote:
On May 26, 1:50 pm, Alexey Smirnov <alexey.smir... @gmail.comwrote :
On May 26, 6:20 pm, harold.gime...@ gmail.com wrote:
document.getEle mentById('dropd own').options.s elected = 0 //
selects the first option
document.getEle mentById('dropd own').selectedI ndex = 0
should help.
Unfortunately it didn't work on Firefox either. Also works fine on IE.
Thanks, though...
It does work. I've tested in FF 2.0
Can you give me the full code of your script, please?
Sure. Basically it looks for text in the txtField, and decides what to
select on the dropdownlist depending on empty string or not...
Here is the javascript function which executes on the onchange event
of the txtField...
function setStatus() {
DropDown = document.getEle mentById('Dropd ownlist');
text= document.getEle mentById('txtFi eld');
if (text.value != "") {
DropDown.select edIndex = 1;
DropDown.disabl ed = true;
} else {
DropDown.disabl ed = false;
}
}
Below is the asp part:
<asp:textbox id="txtField" runat="server" onchange="setSt atus()">
<ASP:DROPDOWNLI ST id="Dropdownlis t" runat="server" >
<ASP:ListItem Value="1">Activ e</ASP:ListItem>
<ASP:ListItem Value="2">Inact ive</ASP:ListItem>
</ASP:DROPDOWNLIS T>
Thanks!
On May 28, 4:27 am, harold.gime...@ gmail.com wrote:
On May 27, 3:54 pm, Alexey Smirnov <alexey.smir... @gmail.comwrote :
On May 27, 9:39 pm, harold.gime...@ gmail.com wrote:
On May 26, 1:50 pm, Alexey Smirnov <alexey.smir... @gmail.comwrote :
On May 26, 6:20 pm, harold.gime...@ gmail.com wrote:
document.getEle mentById('dropd own').options.s elected = 0 //
selects the first option
document.getEle mentById('dropd own').selectedI ndex = 0
should help.
Unfortunately it didn't work on Firefox either. Also works fine on IE.
Thanks, though...
It does work. I've tested in FF 2.0
Can you give me the full code of your script, please?
Sure. Basically it looks for text in the txtField, and decides what to
select on the dropdownlist depending on empty string or not...
Here is the javascript function which executes on the onchange event
of the txtField...
Hello Harald,
your code is working on my box in IE7, and FF2. It does change an item
in 'Dropdownlist' on onchange event.
Here's my test code (basically, a copy of your code)
<%@ Page Language="VB" %>
<script runat=server>
Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArg s)
Handles Me.Load
If Page.IsPostBack Then
response.write( "SelectedValue= " &
Dropdownlist.Se lectedValue)
End If
End Sub
</script>
<html>
<head runat="server">
<title></title>
<script>
function setStatus() {
DropDown = document.getEle mentById('Dropd ownlist');
text= document.getEle mentById('txtFi eld');
if (text.value != "") {
DropDown.select edIndex = 1;
//DropDown.disabl ed = true;
} else {
DropDown.select edIndex = 0;
//DropDown.disabl ed = false;
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:textbox id="txtField" runat="server"
onchange="setSt atus()" />
<ASP:DROPDOWNLI ST id="Dropdownlis t" runat="server" >
<ASP:ListItem Value="1">Activ e</ASP:ListItem>
<ASP:ListItem Value="2">Inact ive</ASP:ListItem>
</ASP:DROPDOWNLIS T>
<asp:Button ID="Button1" runat="server" Text="PostBack" />
</form>
</body>
</html>
In FireFox I see the same behavior, once text is changed and focus is
changed to other control it executes the setStatus() function. When
the button is clicked you will see that the code behind also get the
right value of the control.
Thoughts?
Alexey
On May 28, 3:30 am, Alexey Smirnov <alexey.smir... @gmail.comwrote :
On May 28, 4:27 am, harold.gime...@ gmail.com wrote:
On May 27, 3:54 pm, Alexey Smirnov <alexey.smir... @gmail.comwrote :
On May 27, 9:39 pm, harold.gime...@ gmail.com wrote:
On May 26, 1:50 pm, Alexey Smirnov <alexey.smir... @gmail.comwrote :
On May 26, 6:20 pm, harold.gime...@ gmail.com wrote:
document.getEle mentById('dropd own').options.s elected = 0 //
selects the first option
document.getEle mentById('dropd own').selectedI ndex = 0
should help.
Unfortunately it didn't work on Firefox either. Also works fine on IE.
Thanks, though...
It does work. I've tested in FF 2.0
Can you give me the full code of your script, please?
Sure. Basically it looks for text in the txtField, and decides what to
select on the dropdownlist depending on empty string or not...
Here is the javascript function which executes on the onchange event
of the txtField...
Hello Harald,
your code is working on my box in IE7, and FF2. It does change an item
in 'Dropdownlist' on onchange event.
Here's my test code (basically, a copy of your code)
<%@ Page Language="VB" %>
<script runat=server>
Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArg s)
Handles Me.Load
If Page.IsPostBack Then
response.write( "SelectedValue= " &
Dropdownlist.Se lectedValue)
End If
End Sub
</script>
<html>
<head runat="server">
<title></title>
<script>
function setStatus() {
DropDown = document.getEle mentById('Dropd ownlist');
text= document.getEle mentById('txtFi eld');
if (text.value != "") {
DropDown.select edIndex = 1;
//DropDown.disabl ed = true;
} else {
DropDown.select edIndex = 0;
//DropDown.disabl ed = false;
}}
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:textbox id="txtField" runat="server"
onchange="setSt atus()" />
<ASP:DROPDOWNLI ST id="Dropdownlis t" runat="server" >
<ASP:ListItem Value="1">Activ e</ASP:ListItem>
<ASP:ListItem Value="2">Inact ive</ASP:ListItem>
</ASP:DROPDOWNLIS T>
<asp:Button ID="Button1" runat="server" Text="PostBack" />
</form>
</body>
</html>
In FireFox I see the same behavior, once text is changed and focus is
changed to other control it executes the setStatus() function. When
the button is clicked you will see that the code behind also get the
right value of the control.
Thoughts?
Alexey
Thanks for that. I helped me identify the issue. The txtField is
actually populated via an RJS Pop Calendar control. Something is
conflicting with the onchange event handler on the txtField and other
code from the pop calendar - BUT, only in FF, which is bizarre to say
the least. The onchange event is not handled by the pop calendar, so
there should be no conflict at all.
I've identified the problem, but still no real solution. I need the
pop calendar since the txtField is supposed to receive a date and I
need to be consistent with the rest of the date input fields...
Alexey, thanks for your help.
-Harold
On May 28, 7:49 pm, harold.gime...@ gmail.com wrote:
Thanks for that. I helped me identify the issue. The txtField is
actually populated via an RJS Pop Calendar control. Something is
conflicting with the onchange event handler on the txtField and other
code from the pop calendar - BUT, only in FF, which is bizarre to say
the least. The onchange event is not handled by the pop calendar, so
there should be no conflict at all.
I've identified the problem, but still no real solution. I need the
pop calendar since the txtField is supposed to receive a date and I
need to be consistent with the rest of the date input fields...
Alexey, thanks for your help.
-Harold- Hide quoted text -
- Show quoted text -
I would suggest to install the Web Developer extension for FF, you
will be able to check js-errors. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: David Knaack |
last post by:
Howdy
I'm new to working with DB2 Universal, so I'm not very familiar with
the tools. I usually only use the Java Control Center and
Configuration Assistant.
I have several clients on the local LAN connecting to an DB2 Universal
8.2 server. If that server goes down for some reason, I'd like to
remotely shut down the client applications (I can do that), then
change the DB2 configuration on the clients to connect to the backup
|
by: ads |
last post by:
hi,
after binding the dropdownlist to a datasource, ive experience this error
"Cannot have multiple items selected in a dropdownlist" after using the code:
dropdownlist.items.findbyvalue("value").selected = true
I didnt specify any selected item in the dropdownlist during binding to the
datasource. I use dropdownlist.clearselection() but still error occurs.
I need information on this. Thanks.
Ads
|
by: Bob Alston |
last post by:
I have an application with several forms. Most forms use radio boxes
for Yes/No choices. On a few of these, once one option is selected, the
user cannot change the selection without moving to another field and
then entering the change on the original checkbox. I should mention
that there is a background image underneath the entire form.
Sometimes I can select any choice and then select the other.
On other sets of Yes/No radio...
|
by: =?Utf-8?B?RGFuaWVs?= |
last post by:
Hi,
How could I change a WCF client endpoint address programatically? The client
is generated by Visual Studio. The purpose of doing this is to use different
service address under different configuration.
Thanks.
Daniel
|
by: myselfgautam.kumar |
last post by:
I have three records into Database. Two of them are already displayed
into datagrid.Third record which is a parameter , I have to select it
from dropdownlist and then insert that record into grid at runtime.
Please, suggest , How to insert record into grid at runtime from
Dropdownlist selected item.And which control should I take into grid,
so that after inserting into grid , I have to save it also.
| |
by: Dhananjay |
last post by:
Hi all,
i have a webpage on which
first thing i am adding record using textboxadd and buttonadd.
------
this works fine
second thing i have dropdownlist box on which i will select an item,
based on this selection , i have another textboxforedit(this textbox
will be populated with dropdownlist box selected item).
in this textboxforedit i will modify the data and i have a update
|
by: Ben |
last post by:
Hi,
i'm trying to get an AJAX modalpopup to confirm if a user really wants
to change a dropdown list value (on the client side) -- if they choose
'No' in the popup, the dropdown list value should stay the same.
anyone know how to accomplish it? i can get the popup to come up on
the onchange, but i'm not sure how to go about to revert the value if
they choose no. even if i put 'return false' in the onchange of the
dropdown, it...
|
by: =?Utf-8?B?U2F0aXNo?= |
last post by:
C#, ASP.NET
Q: Have a formview, with a dropdownlist which is bound to a column. This
dropdownlist has a datasource of DataSet type. Now my objective is, on
Selection Changed of this DropdownList, I need to populate a couple of
TextBox's. How can I do this? What event does the code go into? The
selectionindexchanged even for the DropDownList does not seem to fire.
Any help is appreciated.
Thanks in advance.
|
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...
|
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...
|
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...
| |
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...
|
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();...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |