Calculating with Input Values In this part of the Application, you calculate a s
ID: 3537076 • Letter: C
Question
Calculating with Input Values
In this part of the Application, you calculate a simple sum from input values. Create a new page in your website. Write a standard head and a script tag in the body. In the script, use prompt methods to collect three numbers from the user. Then, use alert methods to display the sum and the product of the three numbers. Note what happens if one or more of the inputs is not a number. Try to explain this behavior. Submit your page to the W3C Validator (http://validator.w3.org/) and correct all errors.
Calculating a Table
Decide on what table you will calculate in this Application and create a new, appropriately named, page in your website. Complete the XHTML code for the head and create a shell for the body. Write an appropriate headline and introductory paragraph and also the XHTML for the table and its header row. Link to this newly created page from your home page.
In place of the data rows for the table, write a <script> tag. Specify text/javascript as the type and as the source (src), use the XHTML page name with the .js extension. For example, if your page is named table.php, use the name table.js as the JavaScript source file.
Now create the table.js file, where you write the JavaScript code. Use a loop that generates one row of the table each time it executes. The document.write function lets you generate both XHTML tags and content for the page. Remember to start and end each row with the <tr> and </tr> tags, and to use the <td> and </td> tags to enclose the calculated values you want to display. The example below calculates 15%, 18%, and 20% tips for meals costing between $8 and $25.
Submit your pages to the W3C Validator (http://validator.w3.org/) and correct all errors. (Note: You may ignore an error concerning placement of the script element.) Include screenshots of the results in your submission. Include the full XHTML code for each page and screenshots of the pages as your web browser displays them. Summarize the steps you followed to create and perfect the website.
Explanation / Answer
I have done the first part. Here is the code. Validated on the site you told. NO ERRORS.
Here is the code. Dont forget to rate. If it helps you. Will try to do second one as well if you want me to do.
code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></meta>
<title>Untitled Form</title>
<script type="text/javascript" >
function checkValidation()
{
var decimal= (/[d]+(.[d]+)?/);
if(element_1.value.match(decimal))
{
if(element_2.value.match(decimal))
{
if(element_3.value.match(decimal))
{
display();
return true;
}
else
{
alert('You have to enter integer or doubles values only. Dont enter any alphabets or special character other than . (dot) ')
return false;
return false;
}
}
else
{ alert('You have to enter integer or doubles values only. Dont enter any alphabets or special character other than . (dot) ')
return false;
return false;
}
}
else
{
alert('You have to enter integer or doubles values only. Dont enter any alphabets or special character other than . (dot) ')
return false;
}
}
function display()
{
var value1 = document.getElementById("element_1").value;
var value2 = document.getElementById("element_2").value;
var value3 = document.getElementById("element_3").value;
var value4 =+value1 + +value2 + +value3;
alert("The total sum is "+value4)
}
</script>
</head>
<body id="main_body" >
<div id="form_container">
<h1><a>Untitled Form</a></h1>
<form id="form_642363" class="appnitro" method="post" action="" >
<div class="form_description">
<h2>Untitled Form</h2>
</div>
<ul >
<li id="li_1" >
<label class="description" for="element_1">Input value 1 </label>
<div>
<input id="element_1" name="element_1" class="element text medium" type="text" maxlength="255" value=""/>
</div>
</li> <li id="li_2" >
<label class="description" for="element_2">Input value 2 </label>
<div>
<input id="element_2" name="element_2" class="element text medium" type="text" maxlength="255" value=""/>
</div>
</li> <li id="li_3" >
<label class="description" for="element_3">Input value 3 </label>
<div>
<input id="element_3" name="element_3" class="element text medium" type="text" maxlength="255" value=""/>
</div>
</li>
<li>
<input id="saveForm" class="button_text" type="submit" name="submit" value="Submit" />
</li>
</ul>
</form>
</div>
</body>
</html>
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.