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
34
S
10
G
2
Posts: 306
Reputation: 3,577

Post » Fri Jan 08, 2016 8:53 pm

An action like this would do it

set text.text to replace(text.text, "5", "")
B
91
S
31
G
99
Posts: 5,199
Reputation: 65,684

Post » Fri Jan 08, 2016 9:21 pm

thank you @R0j0hound
Image
B
34
S
10
G
2
Posts: 306
Reputation: 3,577


Return to How do I....?

Who is online

Users browsing this forum: gomotion100, Yahoo [Bot] and 9 guests