top of page

Forum Posts

Alison Upton
Apr 16, 2019
In Coding with Velo
Hi I'm relatively new to this all so please excuse the basic question! - I have some text that I'd like to display 100 words of and then #showmore using a show more and a #showless button. - It seems that the default display (short text) removes the first 100 characters, rather than displaying them! Any assistance would be great, thanks very much! Here is my code: let fullText; // variable to hold the full text let shortText; // variable to hold the short version of the text $w.onReady(function () { // how many characters to include in the shortened version const shortTextLength = 100; // read the full text and store it in the fullText variable fullText = $w("#text15").text; // grab the number of characters defined in shortTextLength and store them in the shortText variable shortText = fullText.substr(100) + "..."; // set the contents of the text element to be the short text $w("#text15").text = shortText; }); export function button2_click(event) { // check the contents of the text element if ($w("#text15").text === shortText) { // if currently displaying short text, display the full text $w("#text15").text = fullText; $w("#button2").label = "Show less"; } else { // if currently displaying full text, display the short text $w("#text15").text = shortText; $w("#button2").label = "Show more"; }}
0
1
380

Alison Upton

More actions
bottom of page