Note that there are some explanatory texts on larger screens.

plurals
  1. POFunction not fully cycling through for loop
    primarykey
    data
    text
    <p>I have formatted the second script so it could be easily read in notepad ++ which is the problematic one, the first is just so you have arrays to work with...Anyways I created this script to replace words with pre-existing numbers in the forms, it works fine cycling through the first key which is "movespeed/movrate" but after when it gets down to str and strrate, it literally cuts off where I have commented <code>//Doesn't get past here?</code> It get's initialized through an onClick (it's a button)</p> <pre><code>&lt;script type="text/javascript"&gt; var key = new Array(); var val = new Array(); key.push("movespeed"); val.push("1"); key.push("str"); val.push("4"); key.push("dex"); val.push("3"); key.push("int"); val.push("1"); key.push("will"); val.push("2"); key.push("Movrate"); val.push("Mov+1"); key.push("strrate"); val.push("1+str"); key.push("dexrate"); val.push("1+dex+(str/4)"); key.push("intrate"); val.push("1+int"); key.push("willrate"); val.push("1+will"); &lt;/script&gt; </code></pre> <p>Apologies if the above script is messing, it was generated by the page..</p> <pre><code>&lt;script type="text/javascript"&gt; function Update() { for (i = 0; i &lt;= key.length; i++) { if (key[i].indexOf("rate") &gt; -1) { //Search through for (r = 0; r &lt;= key.length; r++) { alert("Checked:" + key[r] + " In:" + key[i]); if (key[i].indexOf(key[r]) &gt; -1) { //Finds out which form it should replace alert("Passed:" + key[r] + " In:" + key[i]); var raw = val[i]; for (y = 0; y &lt;= key.length; y++) { if (key[i] != "movespeed" &amp;&amp; key[i] != "Movrate") { //add a check to see if string is not there //alert("string:"+raw); //raw=raw.replace(key[y],Number(document.getElementById(key[y]).value)); raw = raw.replace(key[y], document.getElementById(key[y]).value); //alert("Changed:"+key[y]); alert(raw); } else break; alert("hi"); } //Doesn't get past here? alert("key[i]:" + key[i] + "Key[r]:" + key[r]); if (raw.indexOf("Mov") &gt; -1) { for (x = 0; x &lt;= key.length; x++) { if (key[x].indexOf("movespeed") &gt; -1) { raw = raw.replace("Mov", document.getElementById(key[x]).value); break; } } } if (raw.indexOf("Lvl") &gt; -1) { raw = raw.replace("Lvl", document.getElementById('Lvl').value); } if (raw.indexOf("Exp") &gt; -1) { raw = raw.replace("Exp", "0"); //Change this to exp...you also need to add an exp to the formula system, derpy. } alert(raw); if (key[i] == "Movrate") { document.getElementById("movespeed").value = eval(raw); } else { document.getElementById(key[i]).value = eval(raw); } break; //So it doesn't keep searching } } } alert(key[i]); } } &lt;/script&gt; </code></pre> <p>Html(It was generated through the php but it should work fine without having to be generated)</p> <pre><code> Files&lt;br&gt;======================&lt;br&gt;Basic.xml&lt;br&gt;======================&lt;br&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;Creature Name:&lt;/td&gt;&lt;td&gt;&lt;input type="Text" name="CName" value="Thing" size="10%"&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Level:&lt;/td&gt;&lt;td&gt;&lt;input type="Text" id="Lvl" name="level" onchange="alert('hi')" value="1" size="10%"&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;movespeed:&lt;/td&gt;&lt;td&gt;&lt;input type="Text" name="movespeed" id="movespeed" value="1" size="10%"&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;str:&lt;/td&gt;&lt;td&gt;&lt;input type="Text" name="str" id="str" value="4" size="10%"&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;dex:&lt;/td&gt;&lt;td&gt;&lt;input type="Text" name="dex" id="dex" value="3" size="10%"&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;int:&lt;/td&gt;&lt;td&gt;&lt;input type="Text" name="int" id="int" value="1" size="10%"&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;will:&lt;/td&gt;&lt;td&gt;&lt;input type="Text" name="will" id="will" value="2" size="10%"&gt;&lt;/td&gt;&lt;/tr&gt;&lt;script type="text/javascript"&gt;var key=new Array();var val=new Array();key.push("movespeed");val.push("1");key.push("str");val.push("4");key.push("dex");val.push("3");key.push("int");val.push("1");key.push("will");val.push("2");key.push("Movrate");val.push("Mov+1");key.push("strrate");val.push("1+str");key.push("dexrate");val.push("1+dex+(str/4)");key.push("intrate");val.push("1+int");key.push("willrate");val.push("1+will");&lt;/script&gt;&lt;tr&gt;&lt;td&gt;&lt;input type="button" name="button" value="Update" onclick="Update();"&gt;&lt;/td&gt;&lt;td&gt;&lt;input type="submit" value="Save"&gt;&lt;/td&gt;&lt;script type="text/javascript"&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload