CompleteNumpty
Technical User
I just keep getting undefined.
example of data below:
{Tillid: "MAINTILL", LineNo: "1", Productcode: "15479", ProductDescription: "Cadent 1 Blk Lagre", SingleSalePrice: "380.0000", …}
{Tillid: "MAINTILL", LineNo: "2", Productcode: "11571", ProductDescription: "Helm 58-62 Mission EVO Silver", SingleSalePrice: "19.9900", …}
JavaScript:
<script>
function format ( object ) {
let data=object;
let x = '';
let txt='';
console.log(object);
//data=object;
try {
if (x != undefined) {
// Executes for declared variables that are not undefined nor null
console.log( 'X is okay ' + x)
} // (Nothing happens)
} catch (x) {
console.log('Catch ' + x) // ReferenceError: x is not defined
}
//Json.parse(data);
for (x in data) {
txt += data[x].Tillid + ' Line No:' + data[x].LineNo + ' ' +data[x].Productcode + ' ' + data[x].ProductDescription+' ' + parseFloat(data[x].LineSalePriceIncDisc).toFixed(2) +"\n";
return '<div class="slider">'+
'<table cellpadding="5" cellspacing="0" border="0" style="padding-left:50px;">'+
'<tr>'+
'<td>Till Name:</td>'+
'<td>'+ data[x].Tillid + '</td>'+
'<td>Product Description:</td>'+
'<td>'+''+'</td>'+
'</tr>'+
'<tr>'+
'<td>Customer Name:</td>'+
'<td>'+ console.log(data[x].ProductDescription) +'</td>'+
'</tr>'+
'<tr>'+
'<td>Extra info:</td>'+
'<td>And any further details here (images etc)...</td>'+
'</tr>'+
'</table>';
}
}
</script>```
{Tillid: "MAINTILL", LineNo: "1", Productcode: "15479", ProductDescription: "Cadent 1 Blk Lagre", SingleSalePrice: "380.0000", …}
{Tillid: "MAINTILL", LineNo: "2", Productcode: "11571", ProductDescription: "Helm 58-62 Mission EVO Silver", SingleSalePrice: "19.9900", …}