JS module
JS module
<!DOCTYPE html>
<html lang="en">
<head>
<title>Fibonacci Series</title>
<script src="script.js"></script>
</head>
<body>
<form onsubmit="getFibonacci();return false;">
<!-- Fill the code -->
Enter the number to get a fibonacci<input type="number" id="fibo" />
<br/>
<input type="submit" id="fibobtn" value="Get Fibonacci numbers"/>
<br/>
<div id="result"></div>
</form>
</body>
</html>
--------------------
}
catch(err){
document.getElementById("result").innerHTML=err;
}
}
function fib(inp_num){
if(inp_num == 0 || inp_num == 1){
return inp_num
} else{
return(fib(inp_num - 1)+fib(inp_num - 2))
}
}
---------------
2.ALLITERATION
<html>
<head><script src="script.js"></script></head>
<body>
<form onsubmit="checkAlliteration();return false;">
</form>
<div id="result"></div>
</body>
</html>
-------------------
//Dont change or delete the try/catch block
function checkAlliteration(){
try{
return false;
}catch(err){
document.getElementById("result").innerHTML="Function checkAlliteration:
"+err;
}
}
function getCount(str){
try{
}catch(err){
document.getElementById("result").innerHTML="Function getCount: "+err;
}
}
function validateSentence(str){
try{
// When any word of str starts with a vowel, return false; else, return true
var words = str.split(' ');
vowels = ['a', 'e', 'i', 'o', 'u'];
for(var i=0; i<words.length;i++){
for(var j=0; j<vowels.length;j++){
if(words[i].startsWith(vowels[j])){
return false;
}
}
}
return true;
}catch(err){
document.getElementById("result").innerHTML="Function validateSentence:
"+err;
}
}
function getScore(str,char){
try{
// Compare the first letter of every word from str with char, calculate and
return the score
var words=str.split(' ');
count = 0;
if(words[0].startsWith(char) && words[1].startsWith(char) &&
words[2].startsWith(char)){
for(var i=0; i<words.length;i++){
if(words[i].startsWith(char)){
count++;
}
}
score =0;
if(count<2){
score=0
}
else{
score = 2+((count -3)*2);
}
return score;
}else{
return 0;
}
}catch(err){
document.getElementById("result").innerHTML="Function getScore: "+err;
}
}
3.UGLY NUMBER
}
function checkUglyNumber(num)
{
// Check whether the num value is an ugly number or not. If yes, return
true. Else, return false
while(num!=1){
if(num%2 === 0){
num/=2;
}
else if(num%3 === 0){
num /=3;
}
else if(num%5 == 0){
num /=5;
}else{
return false;
}
}
return true;
}
-------------
4. MAXI INTERIOR MART
<!--Write necessary code wherever needed to complete this code challenge -->
<!DOCTYPE html>
<html>
<head>
<title>Maxi Interior Mart</title>
<style>
input[type="number"],input[type="text"]{
width:98%;
}
select{
width: 99%;
}
*{
font-weight:bold;
}
tr{
background-color: #506B70 ;
}
input:nth-child(even) {
background-color: #dddddd;
}
body{
background-color:#336699;
background-repeat: no-repeat;
background-size: 100%;
margin-top: 7%;
margin-bottom: 7%;
}
div{
margin-left: auto;
margin-right: auto;
text-align: center;
}
h3{
/* Fill the attributes and values */
color:#FFFFFF;
background-color:#242e39;
text-align: center;
width:50%;
margin-left: auto;
margin-right: auto;
font-size: 25px;
padding: 10px;
border-radius:6px;
}
table, td{
margin-left: auto;
margin-right: auto;
font-family: arial;
color:#FFFFFF;
border-collapse: collapse;
width: 50%;
border: 1px solid #242e39;
text-align: left;
padding: 8px;
}
#submit{
text-align: center;
border-radius: 6px;
color: #FFFFFF;
background-color: #042A2C;
width: 50%;
padding: 5px;
}
#result{
/* Fill the attributes and values */
color: #7A000A;
font-size: 20px;
}
</style>
</head>
<body>
<script type="text/javascript" >
function calculate()
{
var material = document.getElementById('material').value;
var height = parseInt(document.getElementById('height').value);
var width = parseInt(document.getElementById('width').value);
var cpsf = 0;
var doorcost = 0;
var totalcost =0;
/* Fill the Javascript code to display the message after
calculating the door cost */
if (material == "Wood"){
cpsf = 200;
}
else{
cpsf = 100;
}
doorcost = (height*width*cpsf);
totalcost = doorcost + (doorcost*7/100);
if(material == "Wood"){
document.getElementById('result').innerHTML = "cost for wood
door is RS. "+totalcost;
}
else{
document.getElementById('result').innerHTML = "cost for PVC
door is RS. "+totalcost;
}
return false;
}
</script>
<div>
<h3>Maxi Interior Mart</h3>
<form onsubmit="return calculate()">
<table>
<tr>
<td>Name</td>
<td><!-- Fill the code for Name -->
<input type="text" required="required" id="name" placeholder="Enter the
name" pattern="[a-zA-Z ]+">
</td>
</tr>
<tr>
<td>Door Material Type</td>
<td><!-- Fill the code for Door Material Type -->
<select name="" id="material">
<option value="Wood">Wood</option>
<option value="PVC">PVC</option>
</select>
</td>
</tr>
<tr>
<td>Door Height (in feet)</td>
<td><!-- Fill the code for Door Height -->
<input type="number" required="required" id="height">
</td>
</tr>
<tr>
<td>Door Width (in feet)</td>
<td><!-- Fill the code for Door Width -->
<input type="number" required="required" id="width">
</td>
</tr>
</table>
<p><input type="submit" id="submit" name="submit" value="SUBMIT"/></p>
<div id="result"> </div>
</form>
</div>
</body>
</html>
-------------------
5. CONCERT TICKET BOOKING
<!--Do not make any change in this code template; add codes in the areas
indicated-->
<!DOCTYPE html>
<html>
<head>
<title>Elektra Waves Concert Ticket Booking</title>
<style>
body{
background-image:url("concert.jpg");
opacity: 0.9;
font-weight: bold;
}
h3, #result, caption{
color: #FFFFFF;
font-family: Verdana;
text-align: center;
}
.title{
color: #000000;
}
#tickettable{
margin-left: auto;
margin-right: auto;
width: 50%;
}
#costchart{
margin-left: auto;
margin-right: 0;
}
td, th{
background-color: #ffffff;
color: #000000;
padding:7px;
border:2px solid #000000;
}
input[type="tel"],select,textarea,input[type="text"]{
width:97%;
}
input[type="range"]{
width:94%;
}
input::placeholder {
color:black;
}
#submit,#clear{
color: #000000;
padding:7px;
border-radius: 5px;
font-weight: bold;
}
#buttons{
margin-left: 40%;
}
</style>
<script src="script.js"> </script>
</head>
<body>
<form onsubmit="return costCalculation();">
<h3>Elektra Waves Concert Ticket Booking</h3><br/>
<table id="tickettable" >
<tr><td colspan="2"><a href="#costchart" id="costchart_ref">View
ticket cost chart</a></td></tr>
-------------------
function show_value(x){
document.getElementById("demo").innerHTML=x;
}
function costCalculation(){
// fill javascript code here - do not use let keyword for variable
intialization; instead use var.
var nooftickets = parseInt(document.getElementById("nooftickets").value);
var tickettype = document.getElementById("ticketType").value;
var coupon = document.getElementById("couponCode");
var refreshment = document.getElementById("refreshment");
var basePrice = 0;
var Total=0;
if(tickettype == "Floor")
{
basePrice = 400;
}
else {
basePrice = 500;
}
var discount = 0;
var refresh = 0;
if(nooftickets>20)
{
discount = 10 + discount;
}
if(coupon.checked === true)
{
discount = 2+discount;
}
if(refreshment.checked === true){
refresh = 100;
}
Total =
Math.round((nooftickets*basePrice)-((basePrice*nooftickets*discount)/100)+refresh);
document.getElementById('result').innerHTML = "your ticket charge is Rs."
+Total;
return false;
}
-----------------------
6.CHALLENGE ACADEMY OF EXCELLENCE
<!--Do not make any change in this code template; add codes in the areas
indicated-->
<!DOCTYPE html>
<html>
<head>
<title>Challenge Academy of Excellence</title>
<link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script
src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script type="text/javascript" src="script.js"></script>
<link rel="stylesheet" href="style.css">
</head>
<body class="demo">
<div id="header" class="page-header"><h1>Challenge Academy of Excellence</h1></div>
<form>
<table>
<tr>
<td colspan="2" class="title">Personal Details</td>
</tr>
<tr>
<td>Name</td>
<td><!-- Fill the code for Name -->
<input type="text" id="name" pattern="[a-zA-Z ]+" required="required"/>
</td>
</tr>
<tr>
<td>Mobile number</td>
<td><!-- Fill the code for Mobile number -->
<input type="text" id="mobilenumber" pattern="[789][0-9]{9}"
required="required">
</td>
</tr>
<tr>
<td>Email Address</td>
<td><!-- Fill the code for Email address -->
<input type="email" id="email" required="required"/>
</td>
</tr>
<tr>
<td>Educational Qualification</td>
<td><select name="" id="education">
<option disabled selected hidden>-Select-</option>
<!-- Fill the code for education qualification options -->
<option value="UG">UG</option>
<option value="PG">PG</option>
<option value="Others">Others</option>
</select>
</td>
</tr>
<tr>
<td>Course Mode</td>
<td><select name="" id='coursemode'>
<option disabled selected hidden>-Select-</option>
<!-- Fill the code for course mode options -->
<option value="Online">Online</option>
<option value="Offline">Offline</option>
</select>
</td>
</tr>
<tr><td class="title">Courses Offered (with duration)</td><td
class="title">Course Fee</td></tr>
<tr><td rowspan="5"><!-- Fill the code for courses -->
<input type="checkbox" name="courses" value="Banking" id="banking">
<label for="banking">Banking</label><br>
<input type="checkbox" name="courses" value="Civil Service" id="civil">
<label for="civil">Civil Services</label><br>
<input type="checkbox" name="courses" value="Railways" id="railways">
<label for="railways">Railways</label><br>
<input type="checkbox" name="courses" value="Police" id="police">
<label for="police">Police</label><br>
<input type="checkbox" name="courses" value="Government Exams"
id="government">
<label for="government">Government Exams</label>
if(totalfees == 0){
document.getElementById('result').innerHTML = "No selection has been
made";
}
else{
document.getElementById('result').innerHTML = "Hi,"+name +"! you are
requested to pay Rs."+ totalfees +" as fees. Details on classes and time slots will
be mailed to "+email+"<br/>Course(s) you've been enrolled in:"+coursename;
}
return false;
}
function selectedCourseName() {
/* Fill the Javascript code - all the selected courses are concatenated
(separated by ;) and returned */
b = document.getElementById('banking');
cs= document.getElementById('civil');
r = document.getElementById('railways');
p = document.getElementById('police');
ge = document.getElementById('government');
var course = "";
if(b.checked){
course = course + "Banking; ";
}
if(cs.checked){
course = course + "Civil Service;";
}
if(r.checked){
course = course + "Railways;";
}
if(p.checked){
course = course + "Police;";
}
if(ge.checked){
course = course + "Government Exams;";
}
return course;
}
function totalFees() {
/* Fill the Javascript code - fees of all the selected courses take part in
calculation and the total fees is returned */
var fee = 0;
b = document.getElementById('banking');
cs = document.getElementById('civil');
r = document.getElementById('railways');
p= document.getElementById('police');
ge= document.getElementById('government');
if(b.checked){
fee += 12300;
}
if(cs.checked){
fee += 15000;
}
if(r.checked){
fee += 7500;
}
if(p.checked){
fee += 8000;
}
if (ge.checked){
fee += 9100;
}
return fee;
}
function totalFees_Online(fees) {
/* Fill the Javascript code - discount of 20% is applied (on the fees
received) and returned */
fee = fees;
return(fee - (fee * 20/100));
}
----------------------------------------
* {
font-weight: bold;
}
body {
background-image: linear-gradient(90deg, rgb(65, 91, 130) 27%, rgb(84, 118,
158) 35%, rgb(70, 134, 174) 46%);
}
#result {
/* Fill the attributes and values */
font-size: 20px;
text-align: center;
color: #ffffff;
}
h1 {
/* Fill the attributes and values */
color: #ffffff;
text-align: center;
}
.title {
/* Fill the attributes and values */
text-align: center;
color:#ffffff;
background-color: #34495E;
font-size: 18px;
font-weight: 500;
}
td {
border-color: #34495E;
background-color: #ffffff;
/* Fill the attributes and values */
padding: 7px;
width: 50%;
border-radius: 5PX;
border-style: solid;
border-width: 2px;
}
table {
/* Fill the attributes and values */
width: 70%;
margin-right: auto;
margin-left: auto;
}
#submit {
margin-left: 45%;
margin-right: auto;
width: 8%;
padding: 5px;
font-size: 18px;
}
input[type="email"], input[type="text"], input[type="number"], select{
width: 75%;
}
----------------------------------
7.ARTICLE (SEMATIC TAGS)
</body>
</html>
-----------------------------------------------------------------
8. MARS MOBILES
<!--Do not make any change in this code template; add codes in the areas
indicated-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<link rel="stylesheet" href="style.css">
<script type="text/javascript" src="script.js"></script>
</head>
<body>
<h1>Mobile Booking Form </h1><hr/>
<form >
<table>
<!--fill the code-->
<tr>
<td>Name</td>
<td><input id="name" type="text" placeholder="Enter the name"></td>
</tr>
<tr>
<td>Email Id</td>
<td><input id="email" type="email" placeholder="[email protected]"></td>
</tr>
<tr>
<td>Contact Number</td>
<td><input id="contact" type="tel" placeholder="Enter Contact
Number"></td>
</tr>
<tr>
<td>Booking Date</td>
<td><input id="bookingDate" type="date" name="" value=""/></td>
</tr>
<tr>
<td>Mobile Model</td>
<td><select id="mobileType">
<option value="-Select Mobile-z">-Select Mobile-</option>
<option value="Oneplus Nord N10">Oneplus Nord N10</option>
<option value="Iphone 13">Iphone 13</option>
<option value="Samsung Galaxy Z">Samsung Galaxy Z</option>
</select>
</td>
</tr>
<tr>
<td>Expected Delivery Date</td>
<td><input id="deliveryDate" type="date" name="" value=""/></td>
</tr>
<tr>
<td>Address</td>
<td><textarea id="address" cols="25" rows="5" placeholder="Enter the
address" name=""></textarea></td>
</tr>
<tr>
<td><input id="btnSubmit" type="submit" value="Place order" name=""
onClick="return calculateCost();"></td>
<td><input id="btnReset" type="reset" value="Clear"></td>
</tr>
</table>
<div id="result"></div>
</form>
</body>
</html>
---------------------------------
//Don't change or delete the try/catch block
function calculateCost(){
try{
var name = document.getElementById("name").value;
var email = document.getElementById("email").value;
var contact = document.getElementById("contact").value;
var mobileType = document.getElementById("mobileType").value;
var bookingDate = document.getElementById("bookingDate").value;
var deliveryDate = document.getElementById("deliveryDate").value;
var address = document.getElementById("address").value;
var vd = validateBookingDate(bookingDate);
if(vd === true){
var vdd = validateDeliveryDate(bookingDate,deliveryDate);
if(vdd === false){
alert("Expected delivery date can't be before the booking date !!")
}else{
var ed = expectedDeliveryDateCheck(bookingDate, deliveryDate);
if(ed === false){
alert("Expected delivery date cannot be same as the booking
date / 1 or 2 days from the booking date !!")
}
else{
var cost = getMobileCost(mobileType);
document.getElementById("result").innerHTML = "The order for "+
mobileType +" has been placed. You need to pay Rs."+ cost;
}
}
}
else{
alert("Booking date should be today !!");
}
}catch(err){
document.getElementById("result").innerHTML="Function calculateCost: "+err;
}
return false;
}
function validateBookingDate(bookingDate){
try{
}catch(err){
document.getElementById("result").innerHTML="Function validateBookingDate:
"+err;
}
}
function validateDeliveryDate(bookingDate,deliveryDate){
try{
var bd = new Date(bookingDate);
var dd = new Date(deliveryDate);
//Validate the deliveryDate as per the description
if(dd.getDate() == bd.getDate() || (dd.getMonth()+1)<(bd.getMonth()+1) ||
dd.getFullYear() < bd.getFullYear()){
return false;
}
else{
return true;
}
}catch(err){
document.getElementById("result").innerHTML="Function validateDeliveryDate:
"+err;
}
}
function expectedDeliveryDateCheck(bookingDate,deliveryDate){
try{
//Validate the deliveryDate as per the description
var bd = new Date(bookingDate);
var dd = new Date(deliveryDate);
if(dd.getDate() == bd.getDate() || (bd.getMonth()+1) < (bd.getMonth()+1) ||
dd.getFullYear() < bd.getFullYear()){
return false;
}
else if((bd.getDate()+1) == dd.getDate() || (bd.getDate()+2) ==
dd.getDate()){
return false;
}
else{
return true;
}
}catch(err){
document.getElementById("result").innerHTML="Function
expectedDeliveryDateCheck: "+err;
}
}
function getMobileCost(mobileType){
try{
-------------------------------
-----------------------------------------------------------------------------------
-------
9.ZOHAN CAMERA STORE
<!--Write necessary code wherever needed to complete this code challenge -->
<!DOCTYPE html>
<html>
<head>
<title>Zohan Camera Store</title>
<style>
input[type="number"],input[type="text"],input[type="tel"],textarea{
width:98%;
}
select{
width: 99%;
}
body{
background-color:#56A6AF;
background-repeat: no-repeat;
background-size: 100%;
margin-top: 7%;
margin-bottom: 7%;
}
div{
margin-left: auto;
margin-right: auto;
text-align: center;
}
h3{
/* Fill the attributes and values */
color : #FFFFFF;
font-size: 25px;
background-color: #27322B;
margin-left: auto;
margin-right: auto;
width: 50%;
font-weight: bold;
padding: 5px;
}
table,tr{
/* Fill the attributes and values */
width: 50%;
margin-left: auto;
margin-right: auto;
background-color: #C4C3CA;
font-family: Arial;
padding: 10px;
}
td{
border: solid 1px black;
/* Fill the attributes and values */
width: 50%;
text-align: left;
color: #453331;
padding: 5px;
}
#submit{
/* Fill the attributes and values */
color: #FFFFFF;
background-color: #323935;
padding: 5px;
width: 50%;
}
#result{
/* Fill the attributes and values */
color: #8D191B;
font-size: 18px;
font-family: Arial;
font-weight: bold;
padding: 10px;
}
</style>
</head>
<body>
<script >
function display()
{
/* Fill the Javascript code to display the message after calculating the total
order cost */
var model=document.getElementById('cameramodel').value;
var code=document.getElementById('couponcode').value;
var quantity=document.getElementById('quantity').value;
var price=0;
var cameracost;
var disPrice;
var totalCost;
<!--Write necessary code wherever needed to complete this code challenge -->
<!--Specify ids as required - do not inlcude unnecessary space -->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>ProTech Service Center</title>
<link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script
src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<style type="text/css">
.demo {
/* Fill the attributes and values */
color: #900043;
font-weight: bold;
font-family: calibri;
}
body {
background-color:#0ca2b9;
width: 80%;
margin-left: 10%;
}
h2 {
/* Fill the attribute and value */
text-shadow: 2px 2px #900043;
color:#FFFFFF;
}
#submit, #reset {
font-weight: bold;
width: 10em;
height: 35px;
border-radius: 10px;
color:#FFFFFF;
}
table {
/* Fill the attributes and values */
width:60%;
margin-left:auto;
margin-right: auto;
}
input,textarea {
width:30em;
}
td{
padding:3px;
}
#yes, #no, #cleaning, #repair, #gas_refill {
width:10pt;
}
#result {
text-shadow: 2px 2px #900043;
/* Fill the attributes and values */
font-style:italic;
color:#FFFFFF;
font-weight: normal;
font-family: Candara;
font-size: 25px;
}
</style>
<script >
function bookAppointment()
{
/* Fill the Javascript code to display the message after calculating
the cost of service */
/* The page SHOULD NOT get redirected AFTER displaying the output */
var name= document.getElementById('customerName').value;
var acType = document.getElementById('acType').value;
var totalserviceCharge = 0;
if(document.getElementById('cleaning').checked){
totalserviceCharge = totalserviceCharge + 500;
}
if(document.getElementById('repair').checked){
totalserviceCharge = totalserviceCharge + 2000;
}
if(document.getElementById('gas_refill').checked){
totalserviceCharge = totalserviceCharge + 1000;
}
if(document.getElementById('yes').checked){
totalserviceCharge = totalserviceCharge + 1000;
document.getElementById('result').innerHTML = "Hello " + name + "!
The estimated Service charge for " +acType + " AC with yearly maintenance is Rs. "
+ totalserviceCharge;
}
else{
document.getElementById('result').innerHTML = "Hello " + name + "!
The estimated Service charge for " +acType + " AC without yearly maintenance is Rs.
" + totalserviceCharge;
}
}
</script>
</head>
<!-- Give the appropriate class name for body as per the description -->
<body class="demo">
<!-- Give the appropriate bootstrap class for header div: to add spacing around the
heading -->
<div id="header" class="page-header">
<h2>ProTech Service Center</h2>
</div>
<!-- Give an appropriate bootstrap class on submit and reset components within the
form given below, as per the description-->
<form onsubmit='bookAppointment(); return false'><!-- Invoke js funtion from form's
onsubmit preceeding the function name by a return keyword-->
<table>
<tr>
<td>Customer Name</td>
<td><!-- Fill the code for Customer Name -->
<input type="text" id="customerName" placeholder="Enter your name"
required/>
</td>
</tr>
<tr>
<td>Mobile Number</td>
<td><!-- Fill the code for Mobile Number -->
<input id='mobileNumber' type="tel" required />
</td>
</tr>
<tr>
<td>Email ID</td>
<td><!-- Fill the code for Email ID -->
<input type="email" placeholder="Enter your email" id="email"
required='required' />
</td>
</tr>
<tr>
<td>Address</td>
<td><!-- Fill the code for Address -->
<textarea id='address' placeholder="Enter your address" rows='5'
cols='25' required></textarea>
</td>
</tr>
<tr>
<td>AC Type</td>
<td><!-- Fill the code for AC Type -->
<input type="text" id="acType" list="acTypes" />
<datalist id='acTypes'>
<option value='Split'>Split</option>
<option value='Window'>Window</option>
</datalist>
</td>
</tr>
<tr>
<td>Service Type</td>
<td><!-- Fill the code for Service Type -->
<input type="checkbox" name="ServiceType" id="cleaning"
value='Cleaning' />
<label for='cleaning'>Cleaning</label>
<input type="checkbox" name="ServiceType" id="repair" value='Repair'
/>
<label for='repair'>Repair</label>
<input type="checkbox" name="ServiceType" id="gas_refill" value='Gas
Refill' />
<label for='gas_refill'>Gas Refill</label>
</td>
</tr>
<tr>
<td>Yearly Maintenance</td>
<td><!-- Fill the code for Yearly Maintenance -->
<input type="radio" id="yes" value='Yes' name='ymaintenance' required/>
<label for='yes'>Yes</label>
<input type="radio" id="no" value="No" name='ymaintenance' required/>
<label for='no'>No</label>
</td>
</tr>
<tr>
<td>Duration in months from previous service</td>
<td><!-- Fill the code for Duration -->
<input type="range" id="duration" min='0' max='6' step='1' title="0 to
6 Months" />
</td>
</tr>
<tr>
<td></td>
<td>
<!--style the submit button such that it indicates successful
action - using the appropriate bootstrap class-->
<input type="submit" id='submit' value="SUBMIT"
class="btn-success" />
<!--style the reset button such that it indicates caution to be
taken with this action - using the appropriate bootstrap class-->
<input type='reset' id='reset' value="CLEAR" class="btn-warning" />
</td>
</tr>
<tr>
<td colspan="2">
<!-- Fill the id value as per the description for displaying the
result -->
<div id="result"></div>
</td>
</tr>
</table>
</form>
</body>
</html>
---------------------------------------------
11.ESSENTIAL EDITIONS
<!--Write necessary code wherever needed to complete this code challenge -->
<!--Specify ids as required - don not inlcude unnecessary space -->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Essential Editions</title>
<link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script
src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script type="text/javascript" src="script.js"></script>
<style>
*{
font-weight: bold;
}
body{
/* Fill the attribute and value */
background-color: #C8A869
}
td{
/* Fill the attributes and values */
border:2px solid #34495E;
width: 50%;
padding: 7px;
border-radius: 5px;
color: #ffffff;
background-color: #7a000a;
}
h1, #result{
/* Fill the attributes and values */
text-shadow: 1px 1px #ffffff;
color: #7a000a;
text-align: center;
}
#result{
/* Fill the attribute and value */
font-size: 20px;
}
.title{
background-color: #7a000a;
color:#ffffff;
}
.price{
height : 90px;
}
table{
width: 60%;
margin-left: auto;
margin-right: auto;
}
#submit{
margin-left: 45%;
font-weight:bold;
color:#ffffff;
padding:7px;
border-radius: 5px;
}
input[type="email"],input[type="text"], input[type="tel"]{
width:97%;
}
textarea{
width:98%;
}
</style>
</head>
<body>
<!-- Give the appropriate bootstrap class for header div: to add spacing
around the heading -->
<div id="header" class="page-header"><h1>Essential Editions</h1></div>
<form>
<table>
<tr>
<td colspan="2" id="title1" class="title">Dear customer, welcome to
Essential Editions Family ! Enjoy your first purchase using 250 super coins (SC)
!!</td>
</tr>
<tr>
<td>Name</td>
<td><!-- Fill the code for Name -->
<input type="text" id="name" required="required"/>
</td>
</tr>
<tr>
<td>Phone Number</td>
<td><!-- Fill the code for Phone Number -->
<input type = "tel" id="phno" placeholder="Enter the registered phone
number only" required="required"/>
</td>
</tr>
<tr>
<td>Email</td>
<td><!-- Fill the code for Email ID -->
<input type="email" id="email" required="required"/>
</td>
</tr>
<tr>
<td>Delivery Address</td>
<td><!-- Fill the code for Address -->
<textarea id="Address" rows="3" cols="50"
required="required"></textarea>
</td>
</tr>
<tr>
<td id="title2" class="title">Combo offers on Essential Oils</td>
<td id="title3" class="title">Payable Amount with Super Coin
option</td>
</tr>
<tr>
<td rowspan="3"><!-- Fill the code for Option1 -->
<input type="checkbox" name="essentials" id="option1"
value="option1"> Exotic Aromas Essential Oils - Lavender oil, Lemongrass oil,
Jasmine oil, Mandarin oil, Rose oil (Pack of 5)<br/><br/>
<!-- Fill the code for Option2 -->
<input type="checkbox" name="essentials" id="option2"
value="option2">All Naturals Aromatherapy Brown Bracelet Combo Set of 12 Essential
Oils - 15 ml Each (Pack of 12)<br/><br/>
<!-- Fill the code for Option3 -->
<input type="checkbox" name="essentials" id="option3"
value="option3"> Precious Aromas Essential Oil Lavender, Rose, Tea Tree, Jasmine,
Ylang Ylang, Mandarin, Lemongrass, Peppermint, Citronella, Pure & Natural (Pack of
9)
</td>
<td id="price1" class="price">Rs.530<br/><s>Rs.1995</s> (73% off)</td>
</tr>
<tr>
<td id="price2" class="price">Rs.899<br/><s>Rs.1799</s> (50% off)</td>
</tr>
<tr>
<td id="price3" class="price">Rs.799<br/><s>Rs.4389</s> (82% off)</td>
</tr>
<tr>
<td colspan="2"><!-- Fill the code for Super coin check -->
<input type="checkbox" name="sc" id="sc" value='yes' >Yes, I want to do
my purchase using super coins !</td>
</tr>
</table>
<br/>
<!-- Give an appropriate bootstrap class on submit component -->
<input type="submit" value="PLACE ORDER" id="submit" class="btn-success"
onclick="return purchaseOnSC()">
</form>
<br/><br/>
<!-- Give the appropriate id for this div as per the description -->
<div id="result"></div>
</body>
</html>
--------------------------------------
function purchaseOnSC()
{
/* When super coin based purchase IS checked, invoke calculatePayableAmount()
function */
/* Specify 3 conditions for 3 possible outputs & for each condition, its
corresponding output statement */
var scoin=250;
var sc = document.getElementById('sc');
price = calculatePayableAmount();
if(sc.checked===true)
{
if(price===0)
{
document.getElementById('result').innerHTML="No selection has been made";
}
else if(price>= 1200)
{
document.getElementById('result').innerHTML="Total payable amount is
Rs."+(price-250);
}
else
{
document.getElementById('result').innerHTML="Total payable amount is
Rs."+price;
}
}
else
{
if(price===0)
{
document.getElementById('result').innerHTML="No selected has been made";
}
else
{
document.getElementById('result').innerHTML="Total payable amount is Rs." +
price;
}
}
return false;
}
function calculatePayableAmount()
{
var price=0;
var o1=document.getElementById('option1');
var o2=document.getElementById('option2');
var o3=document.getElementById('option3');
if(o1.checked===true)
{
price=price+430;
}
if(o2.checked===true)
{
price=price+850;
}
if(o3.checked===true)
{
price=price+650;
}
return price;
}