I am trying to modify the script to work again in a period.
I have tried it, but it seems that both texts are repeated with the same text.
& lt; Html & gt; & Lt; Top & gt; & Lt; Script & gt; Var found; Var character; Function Changes (DCPS, Encapsane) {var randstring = ""; Var rslength = chars.length - got.length; Var decrypted = document.getElementById (decSpan); Var encrypted = document.getElementById (encspen); For (var x = 0; x & lt; rslength; x ++) {i = math.flur (Math.rendum) * chars.length); Random String + = Characters. Chart (i); } If (randstring.chart (0) == chairs.chart (got length)) {found = = randstring.chart (0); Decrypted.innerHTML = found; } Else {encrypted.innerHTML = randstring; } If (chars.length &'ve gt; get. Length) {setTimeout ( "(" + + DCPS + "," + Anspan + " '' '10');} Else {encrypted.innerHTML =" "; }} function startdecrypt () {var decodeSpans = [ "decoded", "decoded2"]; Var Ancodspens = [ "encoded", "encoded for 2"]; (Dikodspens in Var Z) {DecSpan = DecodeSpans [Z]; Ankspan = Ancodspens [Z]; Var decrypted = document.getElementById (decSpan); Var encrypted = document.getElementById (Ankspen); Chars = decrypted.inner HTML; Decrypted.innerHTML = ""; found = ""; SetTimeout ( "change ( "+ Disisapia + '" + Ankspan + "')", 10);}} & Lt; / script & gt; & Lt; / head & gt; & Lt; body b gcolor = "# Ffffff" text = "# 000000" & gt; & Lt; input type = "button" value = "go" onClick = "javascript: startdecrypt ()" & gt; & lt; br & gt; & Lt ; span id = "decoded" & gt; Test 1 & lt; / span & gt; & lt; span id = "encoded" & gt; & lt; / span & gt; & lt; br & gt; & Lt; Span id = "decoded2"> Test 2 & lt; span id = "encoded2" & gt; & Lt; / Span & gt; & Lt; / Body & gt; & Lt; / Html & gt;The problem is that the script uses the global javascript variable:
charsandfoundare set tostartdecryptand later used in thechangefunction. Thus, the next occurrence of the loop overrides the previously set values.The best solution is to include them in the JS call of the
changefunction, as if you do with the ID.Also, be sure to declare a local JS variable to avoid such side effects:
var got = "".
Comments
Post a Comment