Java/Html Help

ssc456

Fully Optimized
Messages
4,280
Morning Guys,

Hopefully just a quick question im assuming with the wide variety of people we have on here someone will know the anser to my question.

I'm very farmiliar with Excel and have a formular id like to intergrae in my website. I've used Visual Basic and from that i can see that the majority of languages will have the same principle but with different wording.

heres my form.

Code:
<form id="form1" name="form1" method="post" action="">
        <label>
        <div align="center"><span class="style3">Total Mileage:
          </span>
          <input type="text" name="mile" id="mile" value="" />
        </div>
        </label>
        <div align="left"><br />
        </div>
        <label>
        
        <div align="left">
          <input type="radio" name="radio" id="bus" value="bus" />
          <span class="style3">Business</span></div>
        </label>
        <div align="left"></div>
        <label>
        
        <div align="left">
          <input type="radio" name="radio" id="res" value="res" />
          <span class="style3">Resedential</span></div>
        </label>
        <div align="center"><br />
          <span class="style3">Cost Of Delivery:</span><br />
        </div>
        <label>
        <div align="center">
          <input type="text" name="sum" id="sum" />
        </div>
        </label>
        <div align="center"><br />
          <input type="button" name="Calculate" id="Calculate" value="Calculate" onclick = calculate()/>
          <br />
        </div>
        <label></label>
        <br />
          </form>

ok heres what i want. when you click calculate button,

lookup the value in mile then if radio button res is ticked times by 0.6 if the bus is ticked times by 0.55 and display the answer in sum.

can someone help me please?

Thanks
 
You should change the name of radio as this is probably a reserved name and change the subsequent code.

var TotalMileage = document.form1.mile.value;
var RadioValue = document.form1.radio.value;
var Total = document.form1.sum;
if(RadioValue == "bus"){
Total.sum = TotalMileage * 0.6;
}
if(RadioValue == "res"){
Total.sum = TotalMileage * 0.55;
}
 
thanks david i did manage to resolve this issue now.

turns out i had to change them from raido to rad
 
Back
Top Bottom