Struggling with writing Javascript if/else statement.
Hello everyone,
So I am a complete beginner at Javascript and I am quite struggling with one of my coursework. I need to write a function which would count the total cost of dress hire taking into account a dress type, cost per day and number of days. I had to use radio buttons for the selection of dress type while days will be entered by someone who will use the website. I've started writing a function but it would be great if you could tell me if I'm going to the right direction.
<script language="javascript">
function calculate(){
var price, days;
var days = getField("days").value;
document
if(document.myform.dresstype[0].checked == true)
price = 60 + (15*days);
else if (document.myform.dresstype[1].checked == true)
price = 90 + (30*days);
else if (document.myform.dresstype[2].checked == true)
price = 120+ (40*days);
else price = 0;
}
</script>
I'm sure probably it's quite silly question, but thanks for your help ![]()
