Getting: SyntaxError: missing : in conditional expression

syntaxerror: missing ; after for-loop initializer
syntaxerror: missing ) after argument list
syntaxerror: missing after property list
syntaxerror: missing exponent
syntax error missing ; before statement
adobe syntaxerror: missing ; before statement
uncaught syntaxerror: missing after argument list onclick
syntax error missing before statement netsuite

I am trying to resolve My issue can some one help me ? My code are

let addClass = (obj) => {obj.classList.add('active-input');}
let removeClass = (obj) => {obj.classList.remove('active-input');}

I am trying to create a form by using below HTML which is concatenating in a variable and then I am updating it on DOM.

<input class="inputFull" list="ozip" id="orZip" name="OrZip" onfocus="addClass(this);this.placeholder=\'\';document.getElementById(\'orTitle\').style.display =\'block\';" onblur="this.value ? removeClass(this);document.getElementById(\'orTitle\').style.display =\'block\'; : document.getElementById(\'orTitle\').style.display =\'none\';this.placeholder=\'Origin postal code\'" placeholder="Origin postal code" autocomplete="off"/>

Can someone explain why I am getting SyntaxError: missing : in conditional expression.

SyntaxError: missing ) after condition, If you are coming from another programming language, it is also easy to add keywords that don't mean the same or have no meaning at all in� The JavaScript exception "missing ; before statement" occurs when there is a semicolon (;) missing somewhere and can't be added by automatic semicolon insertion (ASI).

In your onblur handler, you've written:

onblur="this.value 
        ? 
        removeClass(this);
        document.getElementById(\'orTitle\').style.display =\'block\'; 
        : 
        document.getElementById(\'orTitle\').style.display =\'none\';
        this.placeholder=\'Origin postal code\'" 

Given that there are two statements (with semicolon ;) between the ternary conditional operator ? : it is causing a syntax error.

I would suggest separately declaring the blur event handler in a JS file or a <script> element using if.. else blocks to mitigate the error.

SyntaxError: missing ; before statement, The JavaScript exception "missing ; before statement" occurs when there is a semicolon (;) missing somewhere and can't be added by� The class expression is one way to define a class in ECMAScript 2015. Similar to function expressions, class expressions can be named or unnamed. If named, the name of the class is local to the class body only.

I suggest to reuse same function and modify the code as below - This will work as you expect:

let toggleClass = (obj) => {
  if(obj.value) {
   obj.classList.remove('active-input')
   document.getElementById("orTitle").style.display = "block";
  } else {
   obj.classList.add('active-input');
   document.getElementById("orTitle").style.display = "none";
   obj.placeholder = "Origin postal code";
  }
}
<input class="inputFull" list="ozip" id="orZip" name="OrZip" onfocus="toggleClass(this)" onblur="toggleClass(this)" placeholder="Origin postal code" autocomplete="off"/>

{solved} SyntaxError: missing ) after condition, {solved} SyntaxError: missing ) after condition something like choice being your condition and 1 being part of your statement and searches for a missing ). The JavaScript exceptions thrown by JSON.parse() occur when string failed to be parsed as JSON.. Message SyntaxError: JSON.parse: unterminated string literal SyntaxError: JSON.parse: bad control character in string literal SyntaxError: JSON.parse: bad character in string literal SyntaxError: JSON.parse: bad Unicode escape SyntaxError: JSON.parse: bad escape character SyntaxError: JSON.parse

JavaScript Error Handling, Let's get this band a'steppin! The Technical Rundown. All JavaScript error objects are descendants of the Error object, or an inherited object� Assignment within the conditional expression It is advisable to not use simple assignments in a conditional expression, because the assignment can be confused with equality when glancing over the code.

syntax error in conditional expression, and getting the following error while executing it: line 13: syntax error in conditional expression line 13: syntax error near `]' line 13: `[[ $a != This chapter introduces the concepts, objects and functions used to work with and perform calculations using numbers and dates in JavaScript. This includes using numbers written in various bases including decimal, binary, and hexadecimal, as well as the use of the global Math object to perform a wide variety of mathematical operations on numbers.

JavaScript Course, JavaScript SyntaxError - Missing name after . operator � JavaScript | Nullish Coalescing Operator � JavaScript Unsigned Right Shift Assignment� I am getting the issue 'token comma expected' with this query I wrote up in advanced query editor. Selecting 'show error' highlights "in" on the second last row - can anyone advise how to fix this? let Source = Folder.Files("P:\\Workforce Planning 2018\\Dashboards\\Datsets\\_A. Data Exports\\D2_LEAVE B

Comments
  • Getting this error onblur. Thanks for help
  • don't do this onblur="this.value ? removeClass();document.getElementById(\'orTitle\').style.display =\'block\'; : document.getElementById(\'orTitle\').style.display =\'none\';this.placeholder=\'Origin postal code\'" use a function and call it
  • Please check this: stackoverflow.com/questions/6259982/… You shuold swap a ; for a :
  • @LeonardoAlvesMachado Reread the question and you'll see it is not what cause the error. Also, both answers make that clear.
  • @LGSon true. I've made a real quick look and found a ; on the first part of the ternary operator and assumed that the error was just it - and if it wasn't, he could figure it out by himself. Anyway, the link I've posted is a reference to create ternary operators - which is better than just fixing an expression in my opinion.