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

HTML ASSIGNMENT Exercise 6.1 Write a JavaScript program which will display a but

ID: 3736588 • Letter: H

Question

HTML ASSIGNMENT

Exercise 6.1 Write a JavaScript program which will display a button and ask user to enter one character and a name. Your program will then put the name inside a box which is formed by using the character entered The following demonstrate a test run when user entered a and a name John Put vour name in aBox get started now! This page says: Type a symbol to border your name, such as a , or # OK Cancel This page says What is your name? oK Cancel The output looks like the following. Your name is bordered by *John

Explanation / Answer

Following is the java script Code:

<html>

<head>

<script type="text/javascript">

function myFunction(){

var symbol = window.prompt("Type a Symbol to border your name such as a * or #");

var name = window.prompt("What is your name?");

document.write("The output looks like the following. Your name is bordered by " + symbol + "." + "<br/>");

var length = name.length;

for(var i = 0 ; i< length+4 ; i++){

document.write(symbol);

}

document.write("<br>");

document.write(symbol+symbol+name+symbol+symbol);

document.write("<br>");

for(var i = 0 ; i< length+4 ; i++){

document.write(symbol);

}

}

</script>

</head>

<body>

<div>

<h4><b>Put Your Name in a Box</b></h4>

<button>get Started Now!</button>

</div>

</body>

</html>