a javascript problem i need solved need to calculate the price for a new car. Us
ID: 3576002 • Letter: A
Question
a javascript problem i need solved need to calculate the price for a new car. Use a textbox for the Last Name. You must verify that the user has entered the Last Name. If a name is not present, display an appropriate message and place the cursor in the textbox.
The Customer ID is 5 digits. If the Customer ID is not numeric, display an appropriate message, clear the textbox, and place the cursor in the textbox. If the Customer ID is not 5 digits, display an appropriate message, clear the textbox, and place the cursor in the textbox.
The Customer Code is derived by placing the first character of the Last Name in front of the Customer ID. For example if the Customer ID is 12345 and the Last Name is Apple, the Customer Code is A12345.
The Base Price must be numeric and greater than 0. If the Base Price is not numeric, display an appropriate message, clear the textbox, and place the cursor in the textbox. If the Base Price is not greater than 0, display an appropriate message, clear the textbox, and place the cursor in the textbox.
The user may select any of the checkboxes. You must add together the option costs and display the amount using two decimal places in the Total Options Cost textbox.
The Subtotal is derived by adding the Base Price, Total Options Cost and $800 for the Destination & Freight charges. Format the Subtotal to two decimal places.
You must check to see that one of the radio buttons for Dealer Discount has been selected. If a radio button has not been selected, display an appropriate message. If Yes was selected, multiply the Subtotal by 12% to compute the discount. If No was selected, no discount is given. Place this amount in the Dealer Discount textbox. Format the Dealer Discount to two decimal places.
To calculate the Final Cost subtract the Dealer Discount from the Subtotal. Format the Final Cost to two decimal places.
Please use a submit button to call a function to check the fields, calculate various fields and create a cookie.
Remember to format the Total Options Cost, Subtotal, Dealer Discount, and Final Cost to 2 decimal places.
Save the Last Name and Final Cost in a cookie. Set the expiration date for the cookie to 2 months. Must be 2 months not 60 days. After a cookie is set, display an appropriate message.
Explanation / Answer
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script>
function cal(){
var lname = document.getElementById('lname').value;
var id = document.getElementById('id').value;
var price = document.getElementById('price').value;
if(id.length<0)
{
alert("Please Enter valid ID");
}
if(isNan(price))
{
return false;
}
var Bill=price+800*totcost-price*12/100;
document.innerText=Bill;
documet.writeln(Bill);
}
</script>
</head>
<body>
<p>Enter Last Name:<input type='text' name='lname'></p>
<p>Enter CustomerId:<input type='text' name='id'></p>
p>Enter Base Price:<input type='text' name='price'></p>
</body>
</html>
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.