Solved

Javascript Issue Please Help

Posted on 2013-12-16
6
349 Views
Last Modified: 2014-01-10
I have a tab control and one of two potential tabs are displayed depending on the selected value of a dropdown box.  The problem is that for some reason whenever "BT10" is selected (and only "BT10") my javascript method breaks and I get the following error:

 JavaScript critical error  SCRIPT1004: Expected ';'

Below is my javascript method to toggle the tabs. If anybody could provide me with an insight as to why this is happening it would be greatly appreciated.

Jason

  function ToggleDamageandTheftTabs() {
              var tabStrip = eo_GetObject('<%=TabStrip1.ClientID%>');
              var typelossvalue = document.getElementById('ddlTypeLoss');
              var myvalue = typelossvalue.options[typelossvalue.selectedIndex].value;
              var tabItemTheft = tabStrip.getTopGroup().getItemByIndex(3);
              var tabItemDamage = tabStrip.getTopGroup().getItemByIndex(4);

              if (myvalue == "BT10") {

                  tabItemTheft.setVisible(true);
                  tabItemDamage.setVisible(false);
               }

              if (myvalue == "DAMAGE") {
                

                  tabItemTheft.setVisible(false);
                  tabItemDamage.setVisible(true);


              }

              if (myvalue == "THEFT") {

                  tabItemTheft.setVisible(true);
                  tabItemDamage.setVisible(false);
              }

              if (myvalue == "BD10") {

                  tabItemTheft.setVisible(false);
                  tabItemDamage.setVisible(true);
              }

             
               if (myvalue == "CD10") {

                  tabItemTheft.setVisible(false);
                  tabItemDamage.setVisible(true);
              }


              if (myvalue == "CT10") {

                  tabItemTheft.setVisible(true);
                  tabItemDamage.setVisible(false);
              }


              if (myvalue == "EIT10") {

                  tabItemTheft.setVisible(false);
                  tabItemDamage.setVisible(true);
              }


              if (myvalue == "EITUR10") {

                  tabItemTheft.setVisible(false);
                  tabItemDamage.setVisible(true);
              }


              if (myvalue == "EET") {

                  tabItemTheft.setVisible(true);
                  tabItemDamage.setVisible(false);
              }


          }

Open in new window

0
Comment
Question by:jazzcatone
6 Comments
 
LVL 7

Assisted Solution

by:dimmergeek
dimmergeek earned 166 total points
ID: 39721772
Can we see the code for the HTML, specifically the drop-down list?  Can you provide a link?
0
 
LVL 25

Expert Comment

by:Lee Savidge
ID: 39721776
STick an alert before the if statements outputting the value of myvalue. Consider changing the if statements to a switch statement.
0
 
LVL 35

Assisted Solution

by:mvidas
mvidas earned 167 total points
ID: 39721788
To go along with what lsavidge said, here is your function using a switch statement for easier control. Note that it continues processing until it reaches a break, so we can use that to account for multiple cases:
function ToggleDamageandTheftTabs() {
              var tabStrip = eo_GetObject('<%=TabStrip1.ClientID%>');
              var typelossvalue = document.getElementById('ddlTypeLoss');
              var myvalue = typelossvalue.options[typelossvalue.selectedIndex].value;
              var tabItemTheft = tabStrip.getTopGroup().getItemByIndex(3);
              var tabItemDamage = tabStrip.getTopGroup().getItemByIndex(4);

              switch (myvalue) {
                  case "BT10":
                  case "THEFT":
                  case "CT10":
                  case "EET":
                      tabItemTheft.setVisible(true);
                      tabItemDamage.setVisible(false);
                      break;

                  case "DAMAGE":
                  case "BD10":
                  case "CD10":
                  case "EIT10":
                  case "EITUR10":
                      tabItemTheft.setVisible(false);
                      tabItemDamage.setVisible(true);
                      break;
              }
          }

Open in new window

Matt
0
 

Author Comment

by:jazzcatone
ID: 39721868
This is unbelieveable. I took Matt's code and used his instead of mine. I still get the same exact  error !! Pretty crazy. For the dropdown I'm using a .net dropdownlist control. .

--Jason

  <asp:DropDownList ID="ddlTypeLoss" AutoPostBack="true"  runat="server" TabIndex="16" >
                                                        <asp:ListItem Value="" Text="SELECT"></asp:ListItem>
                                                        <asp:ListItem Value="DAMAGE" Text="DAMAGE"></asp:ListItem>
                                                        <asp:ListItem Value="THEFT" Text="THEFT"></asp:ListItem>
                                        </asp:DropDownList>

// also I have some C# code that populates it depending on the selection of another //dropdownlist

     protected void RebindddlTypeLossForURI()
        {
            if (ddlAccount.SelectedValue.Trim().ToUpper() == "URI2")
            {
                ddlTypeLoss.Items.Add(new ListItem("DAMAGE ON UR PREMISE", "BD10", true));
                ddlTypeLoss.Items.Add(new ListItem("THEFT FROM UR PREMISE", "BT10", true));
                ddlTypeLoss.Items.Add(new ListItem("RENTED EQUIPMENT DAMAGE", "CD10", true));
                ddlTypeLoss.Items.Add(new ListItem("RENTED EQUIPMENT THEFT", "CT10", true));
                ddlTypeLoss.Items.Add(new ListItem("EQUIPMENT DAMAGED IN TRANSIT OUTSIDE HAULER", "EIT10", true));
                ddlTypeLoss.Items.Add(new ListItem("EQUIPMENT DAMAGED IN TRANSIT UR HAULER", "EITUR10", true));
                ddlTypeLoss.Items.Add(new ListItem("EMPLOYEE TOOL LOSS", "EET", true));
            }
            else
            {


                string[] strArray = new string[] { "BD10", "BT10", "CD10", "CT10", "EIT10", "EITUR10", "EET" };

                int i = 0;
                for (i = 0; i < strArray.Length; i++)
                {
                    ListItem itemToRemove = ddlTypeLoss.Items.FindByValue(strArray[i]);
                    if (itemToRemove != null)
                    {
                        ddlTypeLoss.Items.Remove(itemToRemove);
                    }

                }



            }

        }

Open in new window

0
 
LVL 44

Accepted Solution

by:
Rainer Jeschor earned 167 total points
ID: 39723949
Hi Jason,

please provide the whole generated HTML - the issue seems to be somewhere else and not inside the code behind.
Thanks.
Rainer
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
What .NET URL re-routing tool did I use? 2 36
SQL Login 17 38
HTML Relative path 9 29
geting geocode of a user with using Google maps api 8 16
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…
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…

914 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now