replace or delete a digit without using array

Get help using Construct 2

Post » Fri Jan 08, 2016 8:44 pm

this number is store in a text.text or variable
12
how can i replace or delete the number 5


like if 12 contain 5
delete 5
= 12

example of the code is here
http://www.w3schools.com/jsref/tryit.as ... f_replace2


<!DOCTYPE html>
<html>
<body>

<p>Click the button to replace "blue" with "red" in the paragraph below:</p>

<p id="demo">12</p>

<button onclick="myFunction()">Try it</button>

<script>
function myFunction() {
var str = document.getElementById("demo").innerHTML;
var res = str.replace(/5/g, "");
document.getElementById("demo").innerHTML = res;
}
</script>

</body>
</html>
Last edited by wizdigitech on Mon Jan 11, 2016 3:54 am, edited 2 times in total.
Image
B
33
S
10
G
2
Posts: 304
Reputation: 3,541

Post » Fri Jan 08, 2016 8:53 pm

An action like this would do it

set text.text to replace(text.text, "5", "")
B
88
S
30
G
89
Posts: 5,107
Reputation: 60,325

Post » Fri Jan 08, 2016 9:21 pm

thank you @R0j0hound
Image
B
33
S
10
G
2
Posts: 304
Reputation: 3,541


Return to How do I....?

Who is online

Users browsing this forum: ilyaTyl, JMonkeyBoss93, LunchboxGames, SoldjahBoy, Yahoo [Bot] and 10 guests