JavaScript Variable Syntax: Unexpected identifier

NickvR

I have the following JavaScript variable I am using in conjunction with Google Maps API.

For some reason I am getting the error

"Uncaught SyntaxError: Unexpected identifier"

I believe it has to do with the 4th line in the following code snip. I do not expect this abut it seems like there is a common syntax issue with the below?

var EditForm = '<p><div class="marker-edit">'+
            '<form method="POST" name="SaveMarker" id="SaveMarker">'+
            '<label for="pType"><span>Product:</span>'+'<input type="text" id="userInput" onkeyup="iwproductFilter()" placeholder="Search for names..">'+'&nbsp;'+
            '<a onclick="document.getElementById('userInput').value = ''; iwproductFilter();" style="font-size:16px;cursor:pointer;"</a>'+'&#10006'+
            '<ul id="myUL">'+'<li id="1a"><a>Adele</a></li>'+'<li id="1b"><a>Agnes</a></li>'+'<li id="1c"><a>Billy</a></li>'+
            '<li id="1d"><a>Bob</a></li>'+'<li id="1e"><a>Calvin</a></li>'+'<li id="1f"><a>Christina</a></li>'+'<li id="1g"><a>Cindy</a></li>'+'<li id="1h"><a>Doug</a></li></ul>'+
            '<select name="pType" class="save-type"><option value="restaurant">Rastaurant</option><option value="bar">Bar</option>'+
            '<option value="house">House</option></select></label>'+
            '<label for="pUserName"><span>Place Name :</span><input type="text" name="pUserName" class="save-name" placeholder="Enter Title" maxlength="40" /></label>'+
            '<label for="pDesc"><span>Description :</span><textarea name="pDesc" class="save-desc" placeholder="Enter Address" maxlength="150"></textarea></label>'+
            '</form>'+
            '</div></p><button name="save-marker" class="save-marker">Add Product</button>';
Highmastdon

Your quotes ' in document.getElementById('userInput').value = '' aren't escaped.

Change it to document.getElementById(\'userInput\').value = \'\' and it'll work

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

error:Syntax Error:ESLint(syntax-parse):unexpected identifier javascript

Syntax Error: Unexpected Identifier

Syntax Error: Unexpected Identifier - Higher Order Function that Returns a Function in JavaScript

JavaScript - Unexpected identifier for loop

JavaScript Unexpected Identifier Highcharts

JavaScript Error: Unexpected Identifier

Unexpected Identifier in Javascript for speech

Javascript Multiline unexpected identifier

Message: syntax error, unexpected '(', expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$'

Parse error: syntax error, unexpected string content "", expecting "-" or identifier or variable or number

GLSL syntax problems: unexpected NEW_IDENTIFIER

Uncaught syntax error unexpected identifier in JS and Html

syntax error, unexpected identifier "header", expecting ")"

ParseError: syntax error, unexpected identifier "JobOpportunities"

Javascript Uncaught SyntaxError: Unexpected identifier

Javascript Unexpected Identifier Error In Console

Thymeleaf onclick Unexpected identifier javascript

Parse error: syntax error, unexpected '"', expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING)

'unexpected token: identifier error' - assigning php json array type variable value to a javascript function from php code

Embeddin PHP into Javascript ,Uncaught SyntaxError: Unexpected identifier

Uncaught SyntaxError: Unexpected identifier (imported class in javascript)

Javascript - Unexpected identifier error message in console

SyntaxError: Unexpected identifier importing React (Javascript)

Uncaught SyntaxError: Unexpected identifier (Javascript Objects)

JavaScript error Uncaught SyntaxError: Unexpected identifier

JavaScript unexpected token syntax error

Javascript syntax error? "Unexpected Indentifier"

Cannot test Vue component with Jest: Syntax error - Unexpected identifier

syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier

TOP Ranking

HotTag

Archive