Solution:
For the second set of code, replace all the “shorttext” and “longtext” elements with a #. ie;
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 = 30;
// read the full text and store it in the fullText variable
fullText = $w(“#text17”).text;
// grab the number of characters defined in shortTextLength and store them in the shortText variable
shortText = fullText.substr(0, shortTextLength) + “…”;
// set the contents of the text element to be the short text
$w(“#text17”).text = shortText;
});
export function button6_click(event, $w) {
// check the contents of the text element
if ($w(“#text17”).text === shortText) {
// if currently displaying short text, display the full text
$w(“#text17”).text = fullText;
$w(“#button6”).label = “Show Less”;
} else {
// if currently displaying full text, display the short text
$w(“#text17”).text = shortText;
$w(“#button6”).label = “Show More”;
}
}
let fullText2; // variable to hold the full text
let shortText2; // variable to hold the short version of the text
$w.onReady( function () {
// how many characters to include in the shortened version
const shortText2Length = 40;
// read the full text and store it in the fullText variable
fullText2 = $w(“#text22”).text;
// grab the number of characters defined in shortTextLength and store them in the shortText variable
shortText2 = fullText2.substr(0, shortText2Length) + “…”;
// set the contents of the text element to be the short text
$w(“#text22”).text = shortText2;
});
export function button7_click(event, $w) {
if ($w(“#text22”).text === shortText2) {
// if currently displaying short text, display the full text
$w(“#text22”).text = fullText2;
$w(“#button7”).label = “Show less”;
} else {
// if currently displaying full text, display the short text
$w(“#text22”).text = shortText2;
$w(“#button7”).label = “Show more”;
}
}
let fullText5; // variable to hold the full text
let shortText5; // variable to hold the short version of the text
$w.onReady( function () {
// how many characters to include in the shortened version
const shortText5Length = 40;
// read the full text and store it in the fullText variable
fullText5 = $w(“#text24”).text;
// grab the number of characters defined in shortTextLength and store them in the shortText variable
shortText5 = fullText5.substr(0, shortText5Length) + “…”;
// set the contents of the text element to be the short text
$w(“#text24”).text = shortText5;
});
export function button8_click(event, $w) {
if ($w(“#text24”).text === shortText5) {
// if currently displaying short text, display the full text
$w(“#text24”).text = fullText5;
$w(“#button8”).label = “Show less”;
} else {
// if currently displaying full text, display the short text
$w(“#text24”).text = shortText5;
$w(“#button8”).label = “Show more”;
}
}