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

x
?
Solved

javascript function not woking.

Posted on 2007-10-09
7
Medium Priority
?
160 Views
Last Modified: 2010-04-16
i have this function that i am checking the passing object to set it.

when I put in the else if statement, I am getting an object expected error. Why???? How do I just make it ignore if set doesnt equal 'set2'????

function checkState(set)
{
      if (set=='set1');
                  {
                  set=['s1','s2','s3','s4'];
                  }
      else if      (set=='set2');
                  {
                  set=['s1','s2','s3','s4'];
                  }
}
0
Comment
Question by:judsonmusic
  • 4
  • 3
7 Comments
 
LVL 35

Expert Comment

by:TimYates
ID: 20041346
You have a semicolon on the end of the

      if (set=='set1');

line

this throws the if statement straight out, so the else is invalid
0
 
LVL 35

Expert Comment

by:TimYates
ID: 20041352
You also have a semicolon on the end of the

      else if      (set=='set2');

line...

Remove them both, and it should work fine
0
 
LVL 3

Author Comment

by:judsonmusic
ID: 20041579
so once I establish this set value, (keep in mind the set value is something like s1,s2,s3,s4

How do I properly initiate this function in the end of the above code once the condition is met ???


function toggleStrat(a,b,c,d,e,f)
{
      toggle(a)
      toggle(b)
      toggle(c)
      toggle(d)
      toggle(e)
}

function toggle(a)
{
      a.className = (a.className=='vis') ? 'novis' : 'vis'
}
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 35

Expert Comment

by:TimYates
ID: 20041886
I'm lost now...  Did the semicolon thing not fix it?

What's this new function?  What are you trying to do?
0
 
LVL 3

Author Comment

by:judsonmusic
ID: 20042726
this is what I am doing, the toggle set is not passing the variables seperately like I need them to.

<script type="text/javascript">

function togglePred(a,b,c)
{
      toggle(a)
      toggle(b)
      toggle(c)
}

function toggleStrat(a,b,c,d,e,f)
{
      toggle(a)
      toggle(b)
      toggle(c)
      toggle(d)
      toggle(e)
}

function toggle(a)
{
      a.className = (a.className=='vis') ? 'novis' : 'vis'
}

function display(a,b,c,d,e,f,g)
{
alert(a);
}


<!---This function will check the state of the check boxes to toggle the strats--->

function checkState(cbs,set)
{
      if             (set=='PP1')
            {
            set=['s1,s2,s3,s4,s5'];
            }            
                  
      else if      (set=='PP2')
            {
            set=['s1','s3','s4','s5','s8'];
            }
            
      else if      (set=='PP3')
            {
            set=['s1','s2','s5','s8'];
            }
            
      else if      (set=='PP4')
            {
            set=['s1','s2','s4'];
            }
            
      else if      (set=='PP5')
            {
            set=['s1','s2','s3','s9'];
            }
            
      else if      (set=='PP6')
            {
            set=['s1','s2','s3','s6','s10'];
            }
            
      else if      (set=='PP7')
            {
            set=['s1','s2','s3','s4','s6'];
            }
            
      else if      (set=='PP8')
            {
            set=['s3','s4','s10'];
            }
            
      else if      (set=='PP9')
            {
            set=['s1','s2','s4','s5','s7','s8'];
            }
            
      else if      (set=='PP10')
            {
            set=['s8'];
            }
            
      else if      (set=='PP11')
            {
            set=['s1','s3','s4','s5','s7','s8','s9'];
            }
            
      else if      (set=='PP12')
            {
            set=['s1','s6','s4'];
            }
                  
       else{
            return;
      }
      {toggle(set)}

}

</script>
0
 
LVL 35

Accepted Solution

by:
TimYates earned 2000 total points
ID: 20042811
Ahh, I see, this is a second question...

Basically, you can't just pass an array to:

  function toggle(a)
  {
      a.className = (a.className=='vis') ? 'novis' : 'vis'
  }

I'm guessing you will need to iterate through the array, call document.getElementById for each of them, and call toggle for each of these in turn...
0
 
LVL 3

Author Comment

by:judsonmusic
ID: 20043292
thanks

      
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

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Suggested Courses
Course of the Month20 days, 10 hours left to enroll

868 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