I have a page I'm trying to write for my gaming site that does a simple calculation for game server admins. The JS works fine when I use the prompt and write methods, but I would rather have it as a form. Unfortunately, I can't get my form to work. I can't get the user data entered in the form to be associated with the variables I created for their data. Here are the scripts.
First one: The JS that works:
<script language="JavaScript" type="text/javascript">
<!--
var upload = parseFloat(prompt("Enter Your Upload Speed:", ""));
var clients = parseInt(prompt("Enter Your Desired Number of Clients: ", ""));
var totalupload = (28.8 * clients)/.9
var MaxClientRate = (upload/clients)*100;
var OptimalClients = upload/28.8
MaxClientRate = Math.round(MaxClientRate * Math.pow(10,0))/Math.pow(10,0);
OptimalClients = Math.round(OptimalClients * Math.pow(10,0))/Math.pow(10,0);
if (MaxClientRate > 2601 && MaxClientRate < 20000)
document.write("<font color=ffffff><br />Your server can
hold " + clients + " clients at a MaxclientRate
of </font>" + MaxClientRate);
else if (MaxClientRate <= 2600)
document.write("<font color=ffffff><br />Sorry, but this
results in a MaxClientRate lower than 2600. Your connection
cannot support this many clients. Please enter a smaller
number in the client field or a larger number in the upload
field.</font>");
else if (MaxClientRate >= 20000)
document.write("<font color=ffffff><br />Your server can
hold " + clients + " clients at a MaxclientRate of 20000.</font>");
if (OptimalClients >= 0)
document.write("<font color=ffffff><br />The Maximum
number of clients your server can hold is </font>" +
OptimalClients);
else
document.write("<font color=ffffff><The Maximum number of
clients your server can hold is 0.");
//-->
</script>
The page that doesn't work is attached. Can someone please help me with this?
First one: The JS that works:
<script language="JavaScript" type="text/javascript">
<!--
var upload = parseFloat(prompt("Enter Your Upload Speed:", ""));
var clients = parseInt(prompt("Enter Your Desired Number of Clients: ", ""));
var totalupload = (28.8 * clients)/.9
var MaxClientRate = (upload/clients)*100;
var OptimalClients = upload/28.8
MaxClientRate = Math.round(MaxClientRate * Math.pow(10,0))/Math.pow(10,0);
OptimalClients = Math.round(OptimalClients * Math.pow(10,0))/Math.pow(10,0);
if (MaxClientRate > 2601 && MaxClientRate < 20000)
document.write("<font color=ffffff><br />Your server can
hold " + clients + " clients at a MaxclientRate
of </font>" + MaxClientRate);
else if (MaxClientRate <= 2600)
document.write("<font color=ffffff><br />Sorry, but this
results in a MaxClientRate lower than 2600. Your connection
cannot support this many clients. Please enter a smaller
number in the client field or a larger number in the upload
field.</font>");
else if (MaxClientRate >= 20000)
document.write("<font color=ffffff><br />Your server can
hold " + clients + " clients at a MaxclientRate of 20000.</font>");
if (OptimalClients >= 0)
document.write("<font color=ffffff><br />The Maximum
number of clients your server can hold is </font>" +
OptimalClients);
else
document.write("<font color=ffffff><The Maximum number of
clients your server can hold is 0.");
//-->
</script>
The page that doesn't work is attached. Can someone please help me with this?