Skip to main content
madeleinel22391508
Known Participant
May 19, 2016
Question

syntax error: invalid default XML namespace

  • May 19, 2016
  • 1 reply
  • 875 views

Hi,

I am receiving this syntax error for my default value in my switch function.  the error I am receiving is "invalid default XML namespace 60 @ line 61"

these are my variables:

var v = this.getField("1").value;

var x = this.getField("2").value;

var y = this.getField("3").value;

this is the line:

default:

app.alert("must select");

break;

}

All i want is the default value to hide var x & y or have an app alert saying the client needs to complete this part if var v = no

very new to switch functions so I apologize if it is a rookie mistake.

This topic has been closed for replies.

1 reply

Inspiring
May 19, 2016

The source of the problem is likely to be in the code that you didn't show.

madeleinel22391508
Known Participant
May 24, 2016

This is the whole code, for this specific part.  I am very new to javascript but after some research I am assuming the error code is saying that a variable was not defined or defined incorrectly? I have no clue, and because I am so new I am still terrible at picking out errors.

// hide I, J, & C.Corp.Type fields;

  1. this.getField("I").display=display.hidden;
  2. this.getField("J").display=display.hidden;
  3. this.getField("C.CorpType").display=display.hidden;

// display fields based on investor type

switch (this.getField("InvestorType").value)

{

case "Individual":

  1. this.getField("I").display=display.visible;

break;

case "Joint":

  1. this.getField("I").display=display.visible;
  2. this.getField("J").display=display.visible;

break;

case "Corp":

  1. this.getField("C.CorpType").display=display.visible;

break;

default:

// no valid investor type;

  1. app.alert("Must select an investor type", 1, 0);

break;

}

var v = this.getField("Accr_InvYN").value;

var x = this.getField("InvestorType").value;

var y = this.getField("CorpType").value;

// set initial state;

this.getField("I.Province").display = display.hidden;

this.getField("I.FName").display = display.hidden;

this.getField("I.Surname").display = display.hidden;

this.getField("I.Sign").display = display.hidden;

this.getField("S").display = display.hidden;

this.getField("J").display = display.hidden;

this.getField("C").display = display.hidden;

this.getField("AOff").display = display.hidden;

this.getField("Acc_Inv").display = display.hidden;

switch(true) {

case (v == "No" || v == "Off"):

     app.alert({cMsg: "Must be an accredited investor to invest in this Fund, please select yes.", nIcon:0});

  break;

case (v == "Yes" && x =="Individual") :

this.getField("I.Province").display=display.visible;

this.getField("I.FName").display=display.visible;

this.getField("I.Surname").display=display.visible;

this.getField("I.Sign").display=display.visible;

this.getField("S").display=display.visible;

this.getField("Acc_Inv").display=display.visible;

break;

case (v == "Yes" && x == "Joint") :

this.getField("I").display=display.visible;

this.getField("J").display=display.visible;

this.getField("S").display=display.visible;

this.getField("Acc_Inv").display=display.visible;

break;

case (v == "Yes" && x == "Corp"):{

this.getField("S").display=display.visible;

this.getField("Acc_Inv").display=display.visible;

break;

default:

app.alert("Must select whether an accredited investor or not", 1, 0);

break;

}

Karl Heinz  Kremer
Community Expert
Community Expert
May 24, 2016

Can I assume that the "a.", "b."... were added by the editor and are not actually part of your code?

There is a "}" missing after the "case (v == "Yes" && x == "Corp"):" case - add one right after the line with "break" and before "default:"

However, your switch statement is wrong: A switch statement expects an expression where you have "true", and that expression is evaluated, and then the individual case statements are executed based on that expression:

switch (a) {

    case 0 :

        // do something

        break;

    case 1:

        // do something

        break;

    default:

        // do something;

};

In this case, the variable "a" is checked to see if it's either equal to "0", or "1", and if not, then the default case is executed.

In your code, you have "switch(true)" - true is always the same, so there is no need to even have a switch statement. Also, you can only have one value associated with a case statement, and not an expression as you are using. See here for more information about the correct syntax: switch - JavaScript | MDN

If you want to treat two different values the same way, you use something like this:

switch (c) {

    case "a" :

    case "b" :

    case "c" :

        // do something

        break;

    case "d" :

        // do something

        break;

    default:

        // do something

}

In this case, the values "a", "b" and "c" all trigger the same block of operations - the one associated with the case "c".

You are mixing different variables in your case statement - a switch construct does not allow that. I would suggest that you use an if/else if/else construct instead.