How can we display Console.log result to an element?

Hello is there a way to display my console.log result to an element? I am using forLoop statement to display a patterned result. Example, display data result on every 10th index. I already solved that but my problem now is how Am I going to display it on my page. Here is my result. Thank you so much.


https://www.wix.com/corvid/forum/community-discussion/populate-table-row-using-forloop

Instead of using console.log() to display, you can use a TextBox. Each line needs to end with a carriage-return/line-feed.

Hello sir @yisrael-wix THANK YOU I GOT IT.

 .then( (items) => {
 let count = items.length;

 for (var e = 0; e<count; e++) {
     let name = items[e].name;
     let grade = items[e].average;
     console.log(e); \\displays all result
     $w("#textBox1").value += name + " " + grade + "\n";
    
}

First, I would suggest using a Text element instead of an input element.

Also, you can’t append to the value of a text box or text element. First build your string, and then set the test element, like this:

let text = ''; 
for (var e = 0; e<count; e++) {
     let name = items[e].name;
     let grade = items[e].average;
     console.log(e); \\displays all result
    text += name + " " + grade + "\n";
}
$w("#textBox1").value = text;

Or, you can first get the value of the text box, append the new line, and then set the value of text box again.

nice! so this is how to set a value outside ForLoop :smiley: Thank you again sir.

@jeffersonuy Well, I see that you were able to append to the textbox. I tried out a loop and it works fine:

 for (i = 1; i < 10; i++) {
    $w('#text1').text += '\n' + i;
 }

The funny thing is, if I do the following it doesn’t work.

$w('#text1').text += i + '\n';

That is, if the newline is at the beginning it works fine, but if it’s at the end it doesn’t work - it’s apparently cut off as white space.

No matter - glad you got it working!

Thank you Sir @yisrael-wix Works perfectly! My next step is to convert the result into PDF. I saw a lot of tutorials on exporting PDF. Hoping it is an easy task :laughing:

Hi Jefferson, since you found alot of tutorials about exporting PDF, could you give me a few links about those tutorials? i will need it in the near future aswel :sweat_smile:

You might want to consider the site monitoring tool instead. Very powerful.

@volkaertskristof hello I only saw it but I never have tried it :sweat_smile: I will going to try it soon. Hoping it is aN easy task lol