Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Ch2: Favorite Car Payoff Form We are still working with the Favorite Car Informa

ID: 3748218 • Letter: C

Question

Ch2: Favorite Car Payoff Form

We are still working with the Favorite Car Information, but this time instead of storing your car information in a variable you will have the user enter their car information into a form. This form will need to have a field for the following; year, make, model, and price. Be sure to use an html field that corresponds to the type of data you are collecting from the user.  

Once the user enters their car info and clicks the submit button then you want to process the data and output a screen that looks just like what you did on the previous assignment.

You are still calculating the payoff of your favorite car in both a 12 month and 24 month schedule. Do not worry about interest.

Your form needs to look similar to this:

Your website output screen needs to look exactly like the one you did for your last assignment:

Make sure you store the year, make, model, and price in a meaningful variable. Ex: $year, $make, $model, etc. You need to put at least 5 comments in your code. Use more if needed. You must use the correct operators to calculate the monthly payoff. All sentences should have proper spacing, spelling, grammar, and punctuation. Format all numbers the way you see them in the example above. Remember to use the <p> tags to create spacing between your sentences.

Explanation / Answer

<html>

<head>

<title> Car payoff </title>
<script>
function validateForm(){

var $year= document.getElementById("yearbought");
var $make = document.getElementById("make");
var $model = document.getElementById("model");
var $price = document.getElementById("price");

var textonlycheck = /^[a-zA-Z]+$/;
var numbers = /^[0-9]+$/;
if($make.match(textonlycheck) && $model.match(textonlycheck) && $price.match(numbers))
{
var $emi = $price/24;
  
var emielement = document.getElementById("emi");
emielement.innerHTML = $emi;
}
else{
alert("Please enter only alphabets");
}

}
</script>
</head>
<body>
<h1> CAR PAYOFF PERIOD CALCULATOR </h1>
<form action="/yourlogic.php" method="post">
<p>
Year the car was bought :: <select name="Year" id="yearbought">
<option value="2018">2018</option>
<option value="2017">2017</option>
<option value="2016">2016</option>
<option value="2015">2015</option>
</select>
</p>

<p>

Make:
<input type="text" id="make" name="make" value="">
</p>
<p>

Model:
<input type="text" id="model" name="model" value="">
</p>
<p>

Price:
<input type="text" id="price" name="price" value="">
</p>
<input type="submit" value="Submit">
<input type="reset">
</form>
<p>Calculated emi is : <input type="text" id="emi"></p>
</body>
</html>