I have a database field that needs to be split into multiple lines delimited by the “|” symbol. I used spit to split the database field into multiple fields in an array. Then used field.length to determine how many fields resulted. Some of the database records may have only 2 or 3 while some have more than 25. Two fields are involved the model_usage field and the comments field. All works as expected with the exception of the very first field?
Webpage: CVOA Website then click on any thumbnail or thumbnail place holder. The field shows up in a corresponding lightbox.
Code:
// For full API documentation, including code examples, visit Velo API Reference - Wix.com
import  {lightbox}  from  ‘wix-window’;
$w.onReady( () => {
let  item = lightbox.getContext();
//   console.log(item)
//   console.log(“===========================================================REPEATER DATA===================================”)
let  repimg = item.image_url;
let  repdesc = item.description;
let  reppart = item.oe_part_no;
let  repapart = item.aftermkt_vendor_part_no;
let  repinterchg = item.aftermkt_interchange;
let  repcomments = item.comments;
let  reptitle = item.title;
let  repUsage = item.model_usage;
$w("#CVPartImg").src = repimg; 
$w("#LBdescription").text  = repdesc; 
$w("#LBoepartno").text = reppart; 
$w("#LBaftermkt").text = repapart; 
$w("#LBinterchange").text = repinterchg;     
// SPLIT THE COMMENTS FIELD
let  input = repcomments;
let  fields = input.split(‘|’);
let  comments;
let  i = 0;
while  ( i < fields.length) {
comments = comments + “\n” + fields[i];
i = i + 1;
}
$w(“#LBcomments1”).text = comments;
//SPLIT MODEL USAGE FOR LBusage1
input = repUsage;
fields = input.split(‘|’);
let  models;
i = 0;
while  ( i < fields.length ) {
models = models + “\n” + fields[i];
i = i + 1;
}
$w(“#LBmodelUsage1”).text = models;
});
Resulting lightbox page:
What is wrong with this code?
