Roy766 Posted July 6, 2008 Share Posted July 6, 2008 Again with this game, I know. I'm trying to make a text box that automatically updates based on the values of the other text boxes. Problem is, it comes up blank :'( Here's what I've got: <html> <head> <title>Combat Game</title> </head> <body> <script language="VBScript"> Sub TotalCosts TotalCost.Value = 200 - swordfootmen.Value - lancefootmen.Value - mountedswordsmen.Value - mountedlancemen.Value - bowmen.Value - horses.Value - catapaults.Value; End Sub </script> You may spend up to 150 gold. For unit prices and stength, consult <a href=unitstuff.php>this graph.</a> <form> Sword-wielding footmen:<input type="text" name="swordfootmen" onChange="TotalCosts"><br> Lance-wielding footmen:<input type="text" name="lancefootmen" onChange="TotalCosts"><br> Mounted sword wielders:<input type="text" name="mountedswordsmen" onChange="TotalCosts"><br> Mounted lance wielders:<input type="text" name="mountedlancemen" onChange="TotalCosts"><br> Bow-wielding footmen:<input type="text" name="bowmen" onChange="TotalCosts"><br> Horses:<input type="text" name="horses" onChange="TotalCosts"><br> Catapults:<input type="text" name="catapults" onChange="TotalCosts"><br> <input type="submit" value="Attack!"><br> <br> <br> Total money left: <input type="text" name="TotalCost" ReadOnly="True"> </form> <?php $sfcost = $_REQUEST['swordfootmen'] * 3; $lfcost = $_REQUEST['lancefootmen'] * 3; $mswcost = $_REQUEST['mountedswordsmen'] * 5; $mlwcost = $_REQUEST['mountedlancemen'] * 5; $bcost = $_REQUEST['bowmen'] * 2; $hcost = $_REQUEST['horses']; $ccost = $_REQUEST['catapults'] * 12; $totalcost = $sfcost + $lfcost + $mswcost + $mlwcost + $hcost + $bcost + $ccost; $sfatk = $_REQUEST['swordfootmen'] * rand(1, 5); $lfatk = $_REQUEST['lancefootment'] * rand(2, 4); $mswatk = $_REQUEST['mountedswordsmen'] * rand(3, 5); $mlwatk = $_REQUEST['mountedlancemen'] * rand(3, 4); $hatk = $_REQUEST['horses']; $batk = $_REQUEST['bowmen'] * rand(1, 4); $catk = $_REQUEST['catapults'] * rand(6, 10); $totalatk = $sfatk + $lfatk + $mswatk + $mlwatk + $batk + $hatk + $catk; $compatk = rand(10, 200); if ( $totalcost > 200 ) { echo "You spent too much money! <br />"; } else { echo "Your total attack force is " . $totalatk . "<br />"; echo 'The computers total attack force is ' . $compatk . "<br />"; if ( $compatk > $totalatk ) { echo 'Sorry, the computer wins...'; } else { echo 'You win! Congratulations!'; } } ?> <br> <br> </body> </html> Link to comment https://forums.phpfreaks.com/topic/113394-vbscript-error-with-auto-update-text-box/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.