0

THis seemed like a simple task, I needed to create a large variable to contain a basic template that would fill a text area's value. I have something very similar working just fine but it seems that when I add quotes ' it seems to throw off the variable and gives me syntax errors. No matter how I do this JS stops at the first single quote it finds and gives me a syntax error.

Uncaught SyntaxError: Unexpected string

If I simply remove the single quotes it works out fine. I made sure that my text is surrounded in double quotes, this is usally what I do when i need to treat single quotes as text.

Here is a very basic example of my code https://jsfiddle.net/b20o28y2/

HTML code:

Here are several js codes i tried so far but I keep getting syntax errors:

var test = "Délai de résolution P3U imputabilité GDI (>8H):

Délai de confirmation d'impact d'affaire par le représentant client (CRC/CRP):

Délai inadéquat de prise en charge CSTI:

Délai d’avis / Processus GDI non respecté:

Délai inadéquat de prise en charge Exploitant:

Manque de connaissances techniques:

Incident causé par un changement technologique:

Délai inadéquat de réalisation de changement:

Surveillance inadéquate (Gestion d’événement):

Récurrence d'incident détectée (Candidat à gestion de problème):

Cause primaire inconnue (Candidat à gestion de problème):
   ";

Here is another method I tried that gives me the syntax errors:

var test = "Délai de résolution P3U imputabilité GDI (>8H):",
"   ",
"Délai de confirmation d'impact d'affaire par le représentant client (CRC/CRP):",
"   ",
"Délai inadéquat de prise en charge CSTI:",
"   ",
"Délai d’avis / Processus GDI non respecté:",
"   ",
"Délai inadéquat de prise en charge Exploitant:",
"   ",
"Manque de connaissances techniques:",
"   ",
"Incident causé par un changement technologique:",
"   ",
"Délai inadéquat de réalisation de changement:",
"   ",
"Surveillance inadéquate (Gestion d’événement):",
"   ",
"Récurrence d'incident détectée (Candidat à gestion de problème):",
"   ",
"Cause primaire inconnue (Candidat à gestion de problème):",
"   ",
$("#valtest").val(test.join("\n"));

This is another method I tried that also gives me syntax errors. I also tried with \R\N at the end and gives me syntax errors:

var test = "Délai de résolution P3U imputabilité GDI (>8H):\n
   \n
Délai de confirmation d'impact d'affaire par le représentant client (CRC/CRP):\n
   \n
Délai inadéquat de prise en charge CSTI:\n
   \n
Délai d’avis / Processus GDI non respecté:\n
   \n
Délai inadéquat de prise en charge Exploitant:\n
   \n
Manque de connaissances techniques:\n
   \n
Incident causé par un changement technologique:\n
   \n
Délai inadéquat de réalisation de changement:\n
   \n
Surveillance inadéquate (Gestion d’événement):\n
   \n
Récurrence d'incident détectée (Candidat à gestion de problème):\n
   \n
Cause primaire inconnue (Candidat à gestion de problème):\n
   \n";

I was reading trough the https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/template_strings but not seeing any documentations on how to deal with this. Would anyone have any info?

josliber
  • 43,891
  • 12
  • 98
  • 133
Daniel Ellison
  • 1,339
  • 4
  • 27
  • 49

0 Answers0