Hello,
I have some text in a #textbox,
I would like all hyphens “-” to be replaced by “/”.
How to do this with code please?
Thanks in advance
Hello,
I have some text in a #textbox,
I would like all hyphens “-” to be replaced by “/”.
How to do this with code please?
Thanks in advance
Like you already said → “replace all” → replaceAll( “curreentString” , “replacedString” )
const myString = 'The quick brown fox jumps over the lazy dog. If the dog reacted, was it really lazy?';
console.log(myString.replaceAll('dog', 'monkey'));
Thank you for your feedback, I wrote its but its not working :
const myString = $w("TextBox1").value;
console.log(myString.replaceAll ('⬚', ' / ')) ;
$w.onReady(function() {
$w('#button1').onClick(()=>{console.log("Button clicked!");
const myString = $w("#TextBox1").value; console.log("TEXT: ", myString);
let myReplacedString = myString.replaceAll ('⬚', ' / ');
console.log("Replaced-Text: ", myReplacedString);
});
});
Thank you very much for your help but the console shows me this:
undefined is not an object (evaluating 'myString.replaceAll')
Show your SETUP!
Don’t you have a TEXT-BOX where you have inserted some TEXT ?
Please use the implemented CONSOLE-LOGS to DEBUG your own CODE.
How to do that?
When you are using google-chrome, or microsotf-edge → press F-12 and navigate to console. Or use the integrated CONSOLE of your wix-editor in preview-mode.
Investigate all results → STEP-by-STEP!
It’s good it’s fixed however the change is displayed in the console but how now to return the modified text in the # textbox1 ?
INIT APP FOR PAGE
[...]
Loading the code for the site. To debug this code, open masterPage.js in Developer Tools.
Loading the code for the Commandez page. To debug this code, open oa2bl.js in Developer Tools.
[datasetReady event] triggered on wix-dataset
Button clicked!
Commandez
Line 5
TEXT: Text ? Test ? Test ? Test
Commandez
Line 6
Replaced-Text: Text / Test / Test / Test
So you got your → REPLACED-TEXT…
let myReplacedString = myString.replaceAll('⬚',' / ');
console.log("Replaced-Text: ", myReplacedString);
Now feed your Text-Box with your gotten results…
$w("#TextBox1").value = myReplacedString;
…or generate a second Text-Box where you want to show the changed results…
$w("#TextBox2").value = myReplacedString;
Super its walk !
Thank you very much for your help and patience.
Good day
Do not forget to like it, if you realy liked it