alert( document.form1.cboType[doc
Main Topics
Browse All TopicsI'm trying to get the SelectedValue from a DropDownList (WebControl) so I can enable / disable other controls based on the values the user has selected. My form is called Form1 and my dropdownlist control is cboType.
Here is my code...
With the definition of the dropdownlist I have onChange="javascript:Contr
<script language="javascript">
function Controls() {
alert( document.form1.cboType[doc
}
<script>
THIS CODE DOES NOT WORK. THE ERROR IS THAT THE OBJECT IS NOT DEFINED.
If I change the code so that the object is passed into the javascript function, everything works fine. Here is the code.
With the definition of the dropdownlist I have onChange="javascript:Contr
<script language="javascript">
function Controls(obj) {
alert( obj[obj.selectedIndex].val
}
<script>
Something must be wrong in my first set of code with respect to how I refer to the dropdownlist (document.Form1.cboType). What have I done wrong in the first example?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
I guess it should be
<script language="javascript">
function Controls() {
alert( document.form1.cboType[doc
}
<script>
or more generally:
<script language="javascript">
function Controls() {
alert( document.forms[0].cboType[
}
<script>
Business Accounts
Answer for Membership
by: TimYatesPosted on 2006-09-04 at 08:11:32ID: 17450116
alert( document.form1.cboType[doc ument.form .cboType.s electedInd ex].value );
you call it "form1" in the first part, then just "form" in the second...
This may be your problem...