[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

uncalled function is breaking javascript on a page

Posted on 2006-04-28
4
Medium Priority
?
313 Views
Last Modified: 2008-03-17
The following function (which builds a list of options for a dropdown select box from an associative array of arrays arOpsOld) is only called when a button is pressed.  However, just having it in my code means that all the other javascript in my page doesn't respond at all.  If I comment this function out, everything else works fine.  This makes me think that I'm doing something silly with my formatting, but my brackets and semicolons all seem to line up.  I do use some of the same variable names in other functions, but if I understand variable scope correctly, that shouldn't matter.  Any ideas?

function opMakeMenuOld(vPlant, vMenuId) {
  var vOptIndex = 0;
  var vSelBoxId = document.getElementById(vMenuId);
  for ( OpId in arOpsOld ) {
    if arOpsOld[OpId][1] = vPlant {
      vSelBoxId.options[vOptIndex] = new Option(arOpsOld[OpId][0], arOpsOld[OpId]);
      vOptIndex++;
    }
  }  
}
0
Comment
Question by:Rakafkaven
  • 3
4 Comments
 
LVL 35

Accepted Solution

by:
TimYates earned 2000 total points
ID: 16562624
   if arOpsOld[OpId][1] = vPlant {

should be:

    if( arOpsOld[OpId][1] == vPlant ) {
0
 
LVL 35

Expert Comment

by:TimYates
ID: 16562630
because you missed the brackets, it would cause the whole bit of javascript to be unparseable, so nothing would run (as you said)

Tim
0
 
LVL 4

Author Comment

by:Rakafkaven
ID: 16562821
That did the trick.  I feel dumb, but grateful!
0
 
LVL 35

Expert Comment

by:TimYates
ID: 16562834
Don't feel dumb!

We all do it now and then, and all you need is another set of eyes to look at it, and it all becomes apparent :-)

Good luck with it!

Tim
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

829 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