0

I have this code:

 facetsString += "<td><input type='checkbox' value=facetList[count].term>&nbsp;&nbsp;" + facetList[count].term +  " (" + facetList[count].count + ")" + "</td>";

I'm trying to give each checkbox a unique value facetList[count].term, but I don't know how to escape the double quotes...

2 Answers 2

5

Just put a backslash in front of the double-quotes:

facetsString += "<td><input type='checkbox' value=\"facetList[count] ... \" /></td>"

Alternatively, you can wrap the outer in single quotes, and use double quotes for property values:

facetsString += '<td><input type="checkbox" value="facetList[count] ... " /></td>'
Sign up to request clarification or add additional context in comments.

Comments

1

You can escape double quotes like this:

"string with \"double qoutes\""

The solution is:

facetsString += "<td><input type='checkbox' value=\"" + facetList[count].term + "\">&nbsp;&nbsp;" + facetList[count].term + " (" + facetList[count].count + ")" + "</td>";

The example provided would write facetList[count].term in the value attribute, and not the actual value of the variable.

2 Comments

facetsString+="<td><input type='checkbox' value=\"facetList[count].term\">&nbsp;&nbsp;"+facetList[count].term+ " (" + facetList[count].count + ")" + "</td>";
value should hav the array item facetList[count].term.. this one is inside a loop...bt im getting the code value="facetList[count].term"

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.