hello,
I have a form that has 10 dropdown lists in one section
each of the dropdowns contain the same data
what i'm looking to do is that when a user selects a value from one
dropdown, change the value to null/nothing for any other dropdowns
that may have had the same value as the one that was just selected.
and have all the dropdowns use the same "selected index changed" code
behind.
so if ddl1 was changed, fire the code behind to sweep thru all the
dropdowns and reset it if there was a match.
was thinking of pseudo code for this would be something like....
assume all the dropdowns are named dd1,dd2,dd3,dd4,dd5,dd6,etc
while I < 11
loop
if newly selected value = "ddl"+I.selectedindex.text then
"ddl"+I.selectedindex = 0
end if
end loop
in javascript there is a function eval() whose parameter is a string.
so results of that call eval("string_to_evaluate") gets executed or
interpreted as if you had type the string out directly.
also, what would be the line of code to tell which dropdown the user
changed and cause the codebehind to trigger? what I was calling
"newly selected value" above
thanks again for any help! 11 22560
simon wrote: hello, I have a form that has 10 dropdown lists in one section each of the dropdowns contain the same data
what i'm looking to do is that when a user selects a value from one dropdown, change the value to null/nothing for any other dropdowns that may have had the same value as the one that was just selected. and have all the dropdowns use the same "selected index changed" code behind.
so if ddl1 was changed, fire the code behind to sweep thru all the dropdowns and reset it if there was a match.
was thinking of pseudo code for this would be something like.... assume all the dropdowns are named dd1,dd2,dd3,dd4,dd5,dd6,etc
while I < 11 loop if newly selected value = "ddl"+I.selectedindex.text then "ddl"+I.selectedindex = 0 end if end loop
in javascript there is a function eval() whose parameter is a string. so results of that call eval("string_to_evaluate") gets executed or interpreted as if you had type the string out directly.
also, what would be the line of code to tell which dropdown the user changed and cause the codebehind to trigger? what I was calling "newly selected value" above
thanks again for any help!
Well you can do your "Eval" thing using reflection. Do a search on "get
control by name" and you'll find some examples about it. However I'd so
something like this.
1. Create an array
Dim A(NumofControls-1) as Array
2. Create your handler code
Private sub Combobox_SelectionChanged(Sender as object, e as EventArgs)
handles DDL1.SelectionChanged, DDL2.SelectionChanged.....
End Sub
3. Make your loop
dim C as ComboBox
dim ChangeBox as ComboBox = DirectCast(Sender, ComboBox)
For ii as integer = 0 to NumofControls-1
C = DirectCast(A(ii), ComboBox)
'Make sure it is not the sender
if not ChangeBox is C then
'Do your check here
End if
Next ii
This code hasn't be checked but the idea is right. Also you'll see here
how do know which object caused the event to fire with this code:
dim ChangeBox as ComboBox = DirectCast(Sender, ComboBox)
Hope is helps
Chris
That is fine for a round trip solution, however, couldn't this solution be
handled at the client. There is no reason to ask the server what to do,
when the client has all of the data.
<select id="box2" name="box2" onchange="cbochanged(this);">
<script language="jscript">
function cbochanged(cbo)
{
var oObject = document.all.item("Select");
for (i = 0; i < oObject.length; i++)
{
if (cbo.id != oObject.id)
{
oObject.selectedIndex=-1;
}
}
}
</script>
"Chris" <no@spam.com> wrote in message
news:ek**************@TK2MSFTNGP15.phx.gbl... simon wrote: hello, I have a form that has 10 dropdown lists in one section each of the dropdowns contain the same data
what i'm looking to do is that when a user selects a value from one dropdown, change the value to null/nothing for any other dropdowns that may have had the same value as the one that was just selected. and have all the dropdowns use the same "selected index changed" code behind.
so if ddl1 was changed, fire the code behind to sweep thru all the dropdowns and reset it if there was a match.
was thinking of pseudo code for this would be something like.... assume all the dropdowns are named dd1,dd2,dd3,dd4,dd5,dd6,etc
while I < 11 loop if newly selected value = "ddl"+I.selectedindex.text then "ddl"+I.selectedindex = 0 end if end loop
in javascript there is a function eval() whose parameter is a string. so results of that call eval("string_to_evaluate") gets executed or interpreted as if you had type the string out directly.
also, what would be the line of code to tell which dropdown the user changed and cause the codebehind to trigger? what I was calling "newly selected value" above
thanks again for any help!
Well you can do your "Eval" thing using reflection. Do a search on "get control by name" and you'll find some examples about it. However I'd so something like this.
1. Create an array Dim A(NumofControls-1) as Array
2. Create your handler code Private sub Combobox_SelectionChanged(Sender as object, e as EventArgs) handles DDL1.SelectionChanged, DDL2.SelectionChanged..... End Sub
3. Make your loop dim C as ComboBox dim ChangeBox as ComboBox = DirectCast(Sender, ComboBox) For ii as integer = 0 to NumofControls-1 C = DirectCast(A(ii), ComboBox) 'Make sure it is not the sender if not ChangeBox is C then 'Do your check here End if Next ii
This code hasn't be checked but the idea is right. Also you'll see here how do know which object caused the event to fire with this code: dim ChangeBox as ComboBox = DirectCast(Sender, ComboBox)
Hope is helps Chris
AMDRIT wrote: That is fine for a round trip solution, however, couldn't this solution be handled at the client. There is no reason to ask the server what to do, when the client has all of the data.
<select id="box2" name="box2" onchange="cbochanged(this);">
<script language="jscript">
function cbochanged(cbo) {
var oObject = document.all.item("Select");
for (i = 0; i < oObject.length; i++) { if (cbo.id != oObject.id) { oObject.selectedIndex=-1; } }
} </script>
"Chris" <no@spam.com> wrote in message news:ek**************@TK2MSFTNGP15.phx.gbl...
simon wrote:
hello, I have a form that has 10 dropdown lists in one section each of the dropdowns contain the same data
what i'm looking to do is that when a user selects a value from one dropdown, change the value to null/nothing for any other dropdowns that may have had the same value as the one that was just selected. and have all the dropdowns use the same "selected index changed" code behind.
so if ddl1 was changed, fire the code behind to sweep thru all the dropdowns and reset it if there was a match.
was thinking of pseudo code for this would be something like.... assume all the dropdowns are named dd1,dd2,dd3,dd4,dd5,dd6,etc
while I < 11 loop if newly selected value = "ddl"+I.selectedindex.text then "ddl"+I.selectedindex = 0 end if end loop
in javascript there is a function eval() whose parameter is a string. so results of that call eval("string_to_evaluate") gets executed or interpreted as if you had type the string out directly.
also, what would be the line of code to tell which dropdown the user changed and cause the codebehind to trigger? what I was calling "newly selected value" above
thanks again for any help!
Well you can do your "Eval" thing using reflection. Do a search on "get control by name" and you'll find some examples about it. However I'd so something like this.
1. Create an array Dim A(NumofControls-1) as Array
2. Create your handler code Private sub Combobox_SelectionChanged(Sender as object, e as EventArgs) handles DDL1.SelectionChanged, DDL2.SelectionChanged..... End Sub
3. Make your loop dim C as ComboBox dim ChangeBox as ComboBox = DirectCast(Sender, ComboBox) For ii as integer = 0 to NumofControls-1 C = DirectCast(A(ii), ComboBox) 'Make sure it is not the sender if not ChangeBox is C then 'Do your check here End if Next ii
This code hasn't be checked but the idea is right. Also you'll see here how do know which object caused the event to fire with this code: dim ChangeBox as ComboBox = DirectCast(Sender, ComboBox)
Hope is helps Chris
Ah, well it is helpful to know that you are using ASP.NET. I thought
your javascript reference was just to illistrate an idea. That's what I
get for being so winform bais.
There is a document.getElementById("DDL1") This should work for you
loop as you can just append the number to "DDL".
My javascript knowledge is very limited though, so I can't help you
beyond this.
Chris
"simon" <me@here.com> schrieb: I have a form that has 10 dropdown lists in one section each of the dropdowns contain the same data
what i'm looking to do is that when a user selects a value from one dropdown, change the value to null/nothing for any other dropdowns that may have had the same value as the one that was just selected. and have all the dropdowns use the same "selected index changed" code behind.
so if ddl1 was changed, fire the code behind to sweep thru all the dropdowns and reset it if there was a match.
was thinking of pseudo code for this would be something like.... assume all the dropdowns are named dd1,dd2,dd3,dd4,dd5,dd6,etc
while I < 11 loop if newly selected value = "ddl"+I.selectedindex.text then "ddl"+I.selectedindex = 0 end if end loop
\\\
Dim ComboBoxes() As ComboBox = _
{ _
Me.ComboBox1, Me.ComboBox2, Me.ComboBox3 _
}
ComboBoxes(i).SelectedIndex = 0
///
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
i just asumed asp.net because simon made a reference to javascript in his
post. Your solution works either way.
"Chris" <no@spam.com> wrote in message
news:eL**************@TK2MSFTNGP09.phx.gbl... AMDRIT wrote: That is fine for a round trip solution, however, couldn't this solution be handled at the client. There is no reason to ask the server what to do, when the client has all of the data.
<select id="box2" name="box2" onchange="cbochanged(this);">
<script language="jscript">
function cbochanged(cbo) {
var oObject = document.all.item("Select");
for (i = 0; i < oObject.length; i++) { if (cbo.id != oObject.id) { oObject.selectedIndex=-1; } }
} </script>
"Chris" <no@spam.com> wrote in message news:ek**************@TK2MSFTNGP15.phx.gbl...
simon wrote:
hello, I have a form that has 10 dropdown lists in one section each of the dropdowns contain the same data
what i'm looking to do is that when a user selects a value from one dropdown, change the value to null/nothing for any other dropdowns that may have had the same value as the one that was just selected. and have all the dropdowns use the same "selected index changed" code behind.
so if ddl1 was changed, fire the code behind to sweep thru all the dropdowns and reset it if there was a match.
was thinking of pseudo code for this would be something like.... assume all the dropdowns are named dd1,dd2,dd3,dd4,dd5,dd6,etc
while I < 11 loop if newly selected value = "ddl"+I.selectedindex.text then "ddl"+I.selectedindex = 0 end if end loop
in javascript there is a function eval() whose parameter is a string. so results of that call eval("string_to_evaluate") gets executed or interpreted as if you had type the string out directly.
also, what would be the line of code to tell which dropdown the user changed and cause the codebehind to trigger? what I was calling "newly selected value" above
thanks again for any help!
Well you can do your "Eval" thing using reflection. Do a search on "get control by name" and you'll find some examples about it. However I'd so something like this.
1. Create an array Dim A(NumofControls-1) as Array
2. Create your handler code Private sub Combobox_SelectionChanged(Sender as object, e as EventArgs) handles DDL1.SelectionChanged, DDL2.SelectionChanged..... End Sub
3. Make your loop dim C as ComboBox dim ChangeBox as ComboBox = DirectCast(Sender, ComboBox) For ii as integer = 0 to NumofControls-1 C = DirectCast(A(ii), ComboBox) 'Make sure it is not the sender if not ChangeBox is C then 'Do your check here End if Next ii
This code hasn't be checked but the idea is right. Also you'll see here how do know which object caused the event to fire with this code: dim ChangeBox as ComboBox = DirectCast(Sender, ComboBox)
Hope is helps Chris
Ah, well it is helpful to know that you are using ASP.NET. I thought your javascript reference was just to illistrate an idea. That's what I get for being so winform bais.
There is a document.getElementById("DDL1") This should work for you loop as you can just append the number to "DDL".
My javascript knowledge is very limited though, so I can't help you beyond this.
Chris
thank you all for your replies. very much appreciate it....
i'm trying to stick with just using VB.net, just because i'm new to it
and want to learn that route. have used other languages before, this
is my new quest :)
i'm going to try using both Chris and Herfrieds solutions (get a more
well rounded understanding of the concepts and syntax)
Herfried, what does the "Me." in "Me.ComboBox1" reference?
Chris, when you define an array in vb.net, you do not need to specify
the type of object it will hold?
"Dim A(NumofControls-1) as Array"
thanks again!
On Mon, 16 Jan 2006 20:58:26 +0100, "Herfried K. Wagner [MVP]" while I < 11 loop if newly selected value = "ddl"+I.selectedindex.text then "ddl"+I.selectedindex = 0 end if end loop
\\\ Dim ComboBoxes() As ComboBox = _ { _ Me.ComboBox1, Me.ComboBox2, Me.ComboBox3 _ } ComboBoxes(i).SelectedIndex = 0 ///
"simon" <me@here.com> schrieb: i'm going to try using both Chris and Herfrieds solutions (get a more well rounded understanding of the concepts and syntax)
Herfried, what does the "Me." in "Me.ComboBox1" reference?
It refers to the instance of the form. You can either type 'Me.ComboBox1'
or 'ComboBox1', which are semantically identical.
Chris, when you define an array in vb.net, you do not need to specify the type of object it will hold?
"Dim A(NumofControls-1) as Array"
Use 'Dim A(...) As Object' instead.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
simon wrote: thank you all for your replies. very much appreciate it.... i'm trying to stick with just using VB.net, just because i'm new to it and want to learn that route. have used other languages before, this is my new quest :)
i'm going to try using both Chris and Herfrieds solutions (get a more well rounded understanding of the concepts and syntax)
Herfried, what does the "Me." in "Me.ComboBox1" reference?
Chris, when you define an array in vb.net, you do not need to specify the type of object it will hold?
"Dim A(NumofControls-1) as Array"
thanks again!
On Mon, 16 Jan 2006 20:58:26 +0100, "Herfried K. Wagner [MVP]"
while I < 11 loop if newly selected value = "ddl"+I.selectedindex.text then "ddl"+I.selectedindex = 0 end if end loop
\\\ Dim ComboBoxes() As ComboBox = _ { _ Me.ComboBox1, Me.ComboBox2, Me.ComboBox3 _ } ComboBoxes(i).SelectedIndex = 0 ///
Me references the current object. If you are in a form, it references
the form. It is not needed, just there for readabilty.
An array will accept an object type. That is why you see me using the
directcast keyword to cast it out of object type back into a combobox.
Chris
thank you guys once again for the quick responses.
chris, in order to use the funtions that are part of the combobox
object, i'd have to cast it out from object to combobox, correct?
chris/herfried - use Object instead of Array, when creating the array
of comboboxes? more accurate?
"Use 'Dim A(...) As Object' instead."
thanks again!
On Mon, 16 Jan 2006 16:42:35 -0500, Chris <no@spam.com> wrote: Me references the current object. If you are in a form, it references the form. It is not needed, just there for readabilty.
An array will accept an object type. That is why you see me using the directcast keyword to cast it out of object type back into a combobox.
simon wrote: thank you guys once again for the quick responses. chris, in order to use the funtions that are part of the combobox object, i'd have to cast it out from object to combobox, correct? chris/herfried - use Object instead of Array, when creating the array of comboboxes? more accurate? "Use 'Dim A(...) As Object' instead."
thanks again!
On Mon, 16 Jan 2006 16:42:35 -0500, Chris <no@spam.com> wrote:
Me references the current object. If you are in a form, it references the form. It is not needed, just there for readabilty.
An array will accept an object type. That is why you see me using the directcast keyword to cast it out of object type back into a combobox.
Since you are new to programming let's leave it at you should cast it
out. It will help save you problems down the line. Also, put "option
strict on" and "option explict on" at the top of your file. This will
help save you errors. It also forces you to do the casting.
Chris
hello chris. thanks again for the tips. been programming for many
years, but brand new to vb/asp and .net
i was assuming Object was the top level class that all classes inherit
from. therefore you would need to cast your object to the appropriate
class in order to have access to methods available at the more
specific level. trying to get a hold of the .net framework concepts
and don't really want to assume anything - especially if i assume it
incorrectly :)
I'll look up those file lines you recommended to learn more about
them.
thanks again for taking the time to reply. people in this group are
much more resonsive than in the forums and its appreciated!
On Mon, 16 Jan 2006 16:58:35 -0500, Chris <no@spam.com> wrote: Since you are new to programming let's leave it at you should cast it out. It will help save you problems down the line. Also, put "option strict on" and "option explict on" at the top of your file. This will help save you errors. It also forces you to do the casting. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: alexandre damiron |
last post by:
Did anyone tried dynamic variable naming in Js, like the ${$varname}
feature of PHP ? It would easier a long DOM generation, for example to
place such a code portion into a loop
....
...
|
by: Russ Chinoy |
last post by:
Hi,
This may be a totally newbie question, but I'm stumped.
If I have a function such as:
function DoSomething(strVarName) {
.....
}
|
by: simon |
last post by:
hello,
i have a form where there are multiple dropdown lists that will all be
populated from the same initial data query.
i have a vb class defined to make the stored proc call and that
returns a...
|
by: Vmusic |
last post by:
Hi,
I am using Javascript to add rows to tables, etc. in a function I am
calling. I pass the function the ID of the div, and what I want in the
rows, and it will add rows to a table in the div.
...
|
by: Anil Gupte |
last post by:
How does one access dynamic controls by name (or wahtever other means)? I
have the following:
Dim newbtnPick As New Button
newbtnPick.Name = "SliceButton" & CurSliceNum
newbtnPick.Location =...
|
by: Anil Gupte |
last post by:
How does one access dynamic controls by name (or whatever other means)? I
have the following:
Dim newbtnPick As New Button
newbtnPick.Name = "SliceButton" & CurSliceNum
newbtnPick.Location =...
|
by: Mark S. |
last post by:
As I understand it, C# doesn't offer dynamic variable names. Below is my
attempted workaround. Is what I'm doing possible?
FYI, I already read all the "why in the world do you need dynamic...
|
by: bprocopio |
last post by:
Please help. I'm stumped.
I need to create a dynamic variable in a procedure that will be used
to update a variable of the same name in a table. i.e. the name in
tblAnalysisScores are...
|
by: Hugh Oxford |
last post by:
How do I get an object's name?
EG.
$obj_FOO = new Bar;
echo $obj_FOO->getName();
'obj_FOO'
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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
|
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...
|
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...
|
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,...
|
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,...
|
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...
|
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...
| |