Question

In: Computer Science

Write, test, and debug (if necessary) JavaScript scripts for the following problem. You must write the...

Write, test, and debug (if necessary) JavaScript scripts for the following problem. You must write the HTML file that references the JavaScript file.

Use prompt to collect names of persons from the user. When the user enters ‘DONE’, your script should stop collecting more names. Then, it should ask the user to specify the following style properties:

Border size? 2px, 5px, or 8px.

Border Color? blue, red, green, and black.

Border style? solid, dotted, dashed, and double.


The HTML document should display the person names in a table using the style properties specified by the user.

Solutions

Expert Solution

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>My Portfolio</title>
    <!-- <link rel="stylesheet" href="index.css"> -->
</head>
<body>
    <div>
        <ul id="list"></ul>
    </div>
    <script src="index.js"></script>
</body>
</html>
window.addEventListener("load",myFun);
let i
let count=0

function myFun(){
    count+=1   
     if(count==1){    //to take inputs only one time
      do{
        i=prompt("enter name")
        if(i!=='DONE'){
            listItem = document.createElement('li')
            listItem.innerHTML = i
            document.getElementById("list").append(listItem)
        }
      }while(i!=="DONE")
    }
}

let borderSize=prompt("enter border in px")
let borderColor=prompt("enter border color")
let borderStyle=prompt("enter border style")

document.getElementById('list').style.borderWidth=borderSize 
document.getElementById('list').style.borderStyle=borderStyle
document.getElementById('list').style.borderColor=borderColor


Related Solutions

Write, test, and debug (if necessary) JavaScript scripts for the following problem. You must write the...
Write, test, and debug (if necessary) JavaScript scripts for the following problem. You must write the HTML file that references the JavaScript file. Use prompt to collect names of persons from the user. When the user enters ‘DONE’, your script should stop collecting more names. Then, it should ask the user to specify the following style properties: - Border size? 2px, 5px, or 8px. - Border Color? blue, red, green, and black. - Border style? solid, dotted, dashed, and double....
Write, test, and debug (if necessary) HTML file with the Javascript codes in an external file...
Write, test, and debug (if necessary) HTML file with the Javascript codes in an external file for the following problem: Input: a number, n, using prompt, which is the number of the factorial numbers to be displayed. Output: a bordered table of numbers with proper caption and headings in which the first column displays the numbers from 1 to n and the second column displays the first n factorial numbers. For example, if a user enters 10 to be the...
For both JavaScript and HTML: ---------------------------------------------------- Write and test JavaScript scripts for the two exercises that...
For both JavaScript and HTML: ---------------------------------------------------- Write and test JavaScript scripts for the two exercises that follow, debug (if necessary).  When required to write a function, you must include a script to test the function with at least two different data sets.  In all cases, for testing, you must write an HTML file that references the JavaScript file. Output an HTML table of the numbers from 2 to 8 along with their squares and cubes. Create a function titled counter that takes...
Objectives: • Learn to write test cases with Junit • Learn to debug code Problem: Sorting...
Objectives: • Learn to write test cases with Junit • Learn to debug code Problem: Sorting Book Objects Download the provided zipped folder from Canvas. The source java files and test cases are in the provided folder. The Book class models a book. A Book has a unique id, title, and author. The BookStore class stores book objects in a List, internally stored as an ArrayList. Also, the following methods are implemented for the BookStore class. • addBook(Book b): sto...
In this exercise, you will test and debug a Future Value Program. The pseudocode of the...
In this exercise, you will test and debug a Future Value Program. The pseudocode of the program is as follows: Display user message WHILE user wants to continue           get monthly investment, yearly interest rate, and years           convert yearly interest rate to monthly interest rate           convert years to months           set the future value to zero           FOR each month                     add monthly investment amount to future value                     calculate interest for month                     add interest to future value          ...
In this exercise, you will test and debug a Future Value Program. The pseudocode of the...
In this exercise, you will test and debug a Future Value Program. The pseudocode of the program is as follows: Display user message WHILE user wants to continue           get monthly investment, yearly interest rate, and years           convert yearly interest rate to monthly interest rate           convert years to months           set the future value to zero           FOR each month                     add monthly investment amount to future value                     calculate interest for month                     add interest to future value          ...
Write two scripts(must be titled “primeSumLoopS” and “primeSumCallS”) in MATLAB that prompts the user to enter...
Write two scripts(must be titled “primeSumLoopS” and “primeSumCallS”) in MATLAB that prompts the user to enter an integer x that 2< x <10000, then the program calculates and displays the sum of the all the prime numbers that are smaller than or equal to x. For example, if x is 11, then the output is 28, which is 2+3+5+7+11. Use two methods: the 1st script uses nested loop and the 2nd script calls another function, primeF.
For this problem, you must use Excel to perform the necessary calculations. Below are the formulas...
For this problem, you must use Excel to perform the necessary calculations. Below are the formulas and equations you will need to use. Click on the image below to download a power point version if the text is blurry or too small. If it is appropirate to use the binomial distribution, use the formula=binom.dist(number_s,trails,probability,cumulative) to calculate the probability. In this formula, number_s is the number of successful trails, trails is the total number of trails, probability is the probability for...
ou must write tests for the following: You must write tests for the following (which may...
ou must write tests for the following: You must write tests for the following (which may include Custom Exceptions): BankAccount Class Tests are written such that any deposit that is made greater than 10000 is not accepted. Tests are written such that balance in the BankAccount does not go below 0. Care should be taken for above tests at the time of Initial Deposit and at the time of Withdrawal and future Deposits. Tests should be written such that the...
Javascript problem: Given an argument of a list of book objects: Example test case input: {...
Javascript problem: Given an argument of a list of book objects: Example test case input: { "title" : "Book A", "pages": "50", "next": { "title": "Book B", "pages": 20, "next": null } } create a recursive function to return the total number total # of pages read in the list. If there are no books in the list, return 0.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT