Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8450821
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:04:51+00:00 2026-06-10T11:04:51+00:00

I have formatted the second script so it could be easily read in notepad

  • 0

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 //Doesn't get past here?
It get’s initialized through an onClick (it’s a button)

<script type="text/javascript">
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");
</script>

Apologies if the above script is messing, it was generated by the page..

<script type="text/javascript">
function Update() {
    for (i = 0; i <= key.length; i++) {
        if (key[i].indexOf("rate") > -1) { //Search through
            for (r = 0; r <= key.length; r++) {
                alert("Checked:" + key[r] + " In:" + key[i]);
                if (key[i].indexOf(key[r]) > -1) { //Finds out which form it should replace
                    alert("Passed:" + key[r] + " In:" + key[i]);
                    var raw = val[i];
                    for (y = 0; y <= key.length; y++) {
                        if (key[i] != "movespeed" && 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") > -1) {
                        for (x = 0; x <= key.length; x++) {
                            if (key[x].indexOf("movespeed") > -1) {
                                raw = raw.replace("Mov", document.getElementById(key[x]).value);
                                break;
                            }
                        }
                    }
                    if (raw.indexOf("Lvl") > -1) {
                        raw = raw.replace("Lvl", document.getElementById('Lvl').value);
                    }
                    if (raw.indexOf("Exp") > -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]);
    }
}
</script> 

Html(It was generated through the php but it should work fine without having to be generated)

   Files<br>======================<br>Basic.xml<br>======================<br><table><tbody><tr><td>Creature Name:</td><td><input type="Text" name="CName" value="Thing" size="10%"></td></tr><tr><td>Level:</td><td><input type="Text" id="Lvl" name="level" onchange="alert('hi')" value="1" size="10%"></td></tr><tr><td>movespeed:</td><td><input type="Text" name="movespeed" id="movespeed" value="1" size="10%"></td></tr><tr><td>str:</td><td><input type="Text" name="str" id="str" value="4" size="10%"></td></tr><tr><td>dex:</td><td><input type="Text" name="dex" id="dex" value="3" size="10%"></td></tr><tr><td>int:</td><td><input type="Text" name="int" id="int" value="1" size="10%"></td></tr><tr><td>will:</td><td><input type="Text" name="will" id="will" value="2" size="10%"></td></tr><script type="text/javascript">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");</script><tr><td><input type="button" name="button" value="Update" onclick="Update();"></td><td><input type="submit" value="Save"></td><script type="text/javascript">
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T11:04:52+00:00Added an answer on June 10, 2026 at 11:04 am

    logic problem, I used i instead of r, changing it to r fixed it completely. Human mistake, thanks everyone though you guys provided some useful tips I wasn’t aware of:

    var check = document.getElementById(key[r]);
                        if (check){
                            document.getElementById(key[r]).value = eval(raw);
                        }
                    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a formatted string from a log file, which looks like: >>> a=test
I have a highly formatted file with large amount of data which I used
I have two long list, one from a log file that contains lines formatted
I have a script partially based on the one here: Upload files with FTP
I have a date formatted like this: 2011-15 The first piece is a 4
First question is: - I have a sql well-formatted string and I want to
Its late and I have been trying to work on a simple script to
I have two arrays of products, both formatted exactly the same, like so: $products
I have formatted my form using uniform jquery plugin. Also for submitting the form
I would like to have formatted, clickable text and images inside a selected UITableViewCell.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.