Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How do you set an alert to make sure that the user has selected a radio button as well as entered some amount of information

How do you set an alert to make sure that the user has selected a radio button as well as entered some amount of information into the contact details section. Below is the example html and javascript.

Pie Order Form

Make your Pie!







Contact Details





Return to Class Menu

var cake_prices = new Array();

cake_prices["Round6"]=20;

cake_prices["Round8"]=25;

cake_prices["Round10"]=35;

cake_prices["Round12"]=75;

var filling_prices= new Array();

filling_prices["None"]=0;

filling_prices["Lemon"]=5;

filling_prices["Custard"]=5;

filling_prices["Fudge"]=7;

filling_prices["Mocha"]=8;

filling_prices["Raspberry"]=10;

filling_prices["Pineapple"]=5;

filling_prices["Dobash"]=9;

filling_prices["Mint"]=5;

filling_prices["Cherry"]=5;

filling_prices["Apricot"]=8;

filling_prices["Buttercream"]=7;

filling_prices["Chocolate Mousse"]=12;

function getCakeSizePrice()

{

var cakeSizePrice=0;

var theForm = document.forms["cakeform"];

var selectedCake = theForm.elements["selectedcake"];

for(var i = 0; i < selectedCake.length; i++)

{

if(selectedCake[i].checked)

{

cakeSizePrice = cake_prices[selectedCake[i].value];

break;

}

}

return cakeSizePrice;

}

function getFillingPrice()

{

var cakeFillingPrice=0;

var theForm = document.forms["cakeform"];

var selectedFilling = theForm.elements["filling"];

cakeFillingPrice = filling_prices[selectedFilling.value];

return cakeFillingPrice;

}

function candlesPrice()

{

var candlePrice=0;

var theForm = document.forms["cakeform"];

var includeCandles = theForm.elements["includecandles"];

if(includeCandles.checked==true)

{

candlePrice=5;

}

return candlePrice;

}

function insciptionPrice()

{

var inscriptionPrice=0;

var theForm = document.forms["cakeform"];

var includeInscription = theForm.elements["includeinscription"];

if(includeInscription.checked==true){

inscriptionPrice=20;

}

return inscriptionPrice;

}

function calculateTotal()

{

var cakePrice = getCakeSizePrice() + getFillingPrice() + candlesPrice() + insciptionPrice();

var divobj = document.getElementById('totalPrice');

divobj.style.display='block';

divobj.innerHTML = "Total Price For the Pie $"+cakePrice;

}

function hideTotal()

{

var divobj = document.getElementById('totalPrice');

divobj.style.display='none';

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

What is Accounting?

Answered: 1 week ago