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

JAVASCRIPT AND HTML <?xml version=\"1.0\" encoding=\"utf-8\"?> <!DOCTYPE html PU

ID: 3914232 • Letter: J

Question

JAVASCRIPT AND HTML

<?xml version="1.0" encoding="utf-8"?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"

"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8"/>

<title>JavaScript HW3</title>

<script type="text/javascript">

function display(num) {

var node = document.getElementById("display");  

node.value+=num;

}

function result(op)

{

document.getElementById("display")=eval(document.getElementById("display").value)

  

}

  

  

</script>

</head>

<body>

<h1>Simple calculator</h1>

<form action="" method="get">

<p>

<input type="text" id="display"/>

</p>

</form>

<form action="" method="get">

<div class="button">

<input type="button" class="btn" name="b7" value="7"/>

<input type="button" class="btn" name="b8" value="8"/>

<input type="button" class="btn" name="b9" value="9"/>

<input type="button" class="btn" name="db" value="/"/><br></br>

<input type="button" class="btn" name="b4" value="6"/>

<input type="button" class="btn" name="b5" value="5"/>

<input type="button" class="btn" name="b6" value="4"/>

<input type="button" class="btn" name="mb" value="*"/><br></br>

<input type="button" class="btn" name="b1" value="3"/>

<input type="button" class="btn" name="b2" value="2"/>

<input type="button" class="btn" name="b3" value="1"/>

<input type="button" class="btn" name="mib" value="-"/><br></br>

<input type="button" class="btn" name="db" value="."/>

<input type="button" class="btn" name="b0" value="0"/>

<input type="button" class="btn" name="eb" value="="/>

<input type="button" class="btn" name="ab" value="+"/><br></br>

</div>

</form>

<!-- W3C XHTML Validation logo-->

<p>

<a href="http://validator.w3.org/check?uri=referer"><img

src="http://www.w3.org/Icons/valid-xhtml11"

alt="Valid XHTML 1.1" height="31" width="88" /></a>

</p>

</body>

</html>

Simple calculator 73 7 8 9 4 5 6* r XHTML ? 1.1

Explanation / Answer

If you have any doubts, please give me comment...

<?xml version="1.0" encoding="utf-8"?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"

"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />

<title>JavaScript HW3</title>

<script type="text/javascript">

function display(num) {

var node = document.getElementById("display");

node.value += num;

}

function result(op) {

var res = eval(document.getElementById("display").value);

document.getElementById("display").value = res;

}

</script>

</head>

<body>

<h1>Simple calculator</h1>

<form action="" method="get">

<p>

<input type="text" id="display" />

</p>

</form>

<form action="" method="get">

<div class="button">

<input type="button" class="btn" name="b7" value="7" />

<input type="button" class="btn" name="b8" value="8" />

<input type="button" class="btn" name="b9" value="9" />

<input type="button" class="btn" name="db" value="/" /><br></br>

<input type="button" class="btn" name="b4" value="6" />

<input type="button" class="btn" name="b5" value="5" />

<input type="button" class="btn" name="b6" value="4" />

<input type="button" class="btn" name="mb" value="*" /><br></br>

<input type="button" class="btn" name="b1" value="3" />

<input type="button" class="btn" name="b2" value="2" />

<input type="button" class="btn" name="b3" value="1" />

<input type="button" class="btn" name="mib" value="-" /><br></br>

<input type="button" class="btn" name="db" value="." />

<input type="button" class="btn" name="b0" value="0" />

<input type="button" class="btn" name="eb" value="=" />

<input type="button" class="btn" name="ab" value="+" /><br></br>

</div>

</form>

<!-- W3C XHTML Validation logo-->

<p>

<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-xhtml11" alt="Valid XHTML 1.1" height="31" width="88" /></a>

</p>

</body>

</html>