?
Solved

Help with Javascript

Posted on 2007-10-06
15
Medium Priority
?
201 Views
Last Modified: 2010-03-30
The following code:

function enableField()
{
alert ( document.vendfrm.lstDemoB1.value);
if ( document.vendfrm.lstDemoB1.value == "D15SPT"){
         document.forms.vendfrm.lstIE1.disabled=false;
       }else{
        document.forms.vendfrm.lstIE1.disabled=true;
       }  
}
 
</script>

Is rendering an alert box with "Undefined" returned.  Can anyone help me on why?

-D-
0
Comment
Question by:John Gates, CISSP
  • 9
  • 4
  • 2
15 Comments
 
LVL 29

Expert Comment

by:chilternPC
ID: 20028592
this code fragment is insuffienct to be able to solve.
obviously something is "undefined" and from the code above
and most of it is
0
 
LVL 18

Author Comment

by:John Gates, CISSP
ID: 20028595
What do you need additional?
0
 
LVL 18

Author Comment

by:John Gates, CISSP
ID: 20028600
Even if I go right from the elements on change event:

<select  name="lstDemoB1" class="narrowfont" style="left:0px; width:220px;" onChange="javascript:document.vendfrm.lstDemoB1.value();"

It returns the same undefined...


-D-
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 18

Author Comment

by:John Gates, CISSP
ID: 20028603
<select  name="lstDemoB1" class="narrowfont" style="left:0px; width:220px;" onChange="javascript:alert (document.vendfrm.lstDemoB1.value());"
0
 
LVL 29

Expert Comment

by:chilternPC
ID: 20028619
what is:

document.vendfrm.lstDemoB1.value()
0
 
LVL 18

Author Comment

by:John Gates, CISSP
ID: 20028631
Whatever value is currently selected from the lstDemoB1 list box.
0
 
LVL 18

Author Comment

by:John Gates, CISSP
ID: 20028632
Unless that's wrong...
0
 
LVL 18

Author Comment

by:John Gates, CISSP
ID: 20028703
Ok this is working in IE but not Mozilla maybe you will be able to help with this:

var w = document.getElementById("lstDemoB1").getAttribute("value")

Does this make anything clearer?

Thanks for hanging in there.

-D-
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 20030169
Try

var w = document.getElementById("lstDemoB1").value;
0
 
LVL 18

Author Comment

by:John Gates, CISSP
ID: 20030206
No go error in Firefox is attribute has no value, same as my code above:

var w = document.getElementById("lstDemoB1").getAttribute("value")


Again yours works as mine does in IE only 8(

-D-
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 20030212
Can you post your html containing those elements?
0
 
LVL 18

Author Comment

by:John Gates, CISSP
ID: 20030215
Code for the item in question:

<select  name="lstDemoB1" class="narrowfont" style="left:0px; width:220px;" onChange="javascript:enableField();">
            <option value=""></option>
                  
             <option value="D09ESH">MIDDLE SCHOOL</option>
             <option value="D15SPT">SPORT CODES</option>
             <option value="D23BRD">BIRTH DATE (MMDDYYbMMDDYY)</option>
             <option value="D50GAP">WEIGHTED ACADEMIC POINTS (0000.00b0000.00)</option>
             <option value="D51GAG">WEIGHTED ACADEMIC GPA (000.0000b000.0000)</option>
             <option value="D52GAR">RANK IN CLASS (0000b0000)</option>
           </select>
            </span>

0
 
LVL 86

Accepted Solution

by:
CEHJ earned 2000 total points
ID: 20030240
Change that to

<select  id="lstDemoB1" name="lstDemoB1" class="narrowfont" style="left:0px; width:220px;" onChange="javascript:enableField();">
0
 
LVL 18

Author Comment

by:John Gates, CISSP
ID: 20030335
Yeah, you know I have run into that once before as well..  Thanks!

-D-
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 20030358
:-)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Suggested Courses
Course of the Month9 days, 19 hours left to enroll

569 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question