Click to See Complete Forum and Search --> : If Command, on a form with radio buttons


Zudane
02-29-2004, 07:16 PM
I need Help... I am making a calculator for a game, and I have it all set up.. except one part. There are bonuses to add to the damage (what my calc figures out), and I want them to be able to select what bonus it is with a radio button, and add that into the calculations.

I have it set so you click submit, and it has an alert that says what damage, and is done in a function.

How can I add this into mine?

If this is confusing.. Let me get the code to show you...

Zudane
02-29-2004, 07:20 PM
Here is the function:

<SCRIPT type="text/javascript">

function doit()
{

var base = document.myform.str.value;
var mod = document.myform.modi.value;

var perc = mod / 100;
var tot = base * (1 + perc);
var hit = tot / 7;


alert("You should hit "
+ Math.round(hit))

}
</SCRIPT>


And the form:

<FORM NAME="myform" action="">
What is your Strength?
<INPUT TYPE="text" NAME="str"><br>
What is your Weapon Power?
<INPUT TYPE="text" NAME="modi"><br><br>
No prayer<INPUT TYPE="radio" NAME="prayer" VALUE="nope">
&nbsp&nbsp Burst of Strength<input type="radio" name="prayer" value="burst">
&nbsp&nbsp Superhuman Strength<INPUT TYPE="radio" NAME="prayer" VALUE="supe">
&nbsp&nbsp Ultimate Strength<INPUT TYPE="radio" NAME="prayer" VALUE="ulti"><br><br>
<INPUT TYPE="button"
VALUE="Submit"
onClick="doit()">
</FORM>


I want it so when they select, say, Burst of strength, it will add 5% to the strength. Can anyone help??? :confused:

Zudane
02-29-2004, 07:36 PM
Ok, I currently have them set to different buttons... so.. I think that will do for now, a seperate function for each.