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...
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...
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.
Write MATLAB scripts to solve problem 5.21 from the textbook (bisection, specific heat) four times: a)...
Write MATLAB scripts to solve problem 5.21 from the textbook (bisection, specific heat) four times: a) with the bisection method (starting interval [0, 1200]) b) with the false-position method (starting interval [0, 1200]) c) with the Newton-Raphson method (x0 = 0) d) with the secant method ((x0, x1) = (0, 1)) use percent relative error = 10^-6 as stopping criterion. 5.21-Mechanical engineers, as well as most other engineers, use thermodynamics extensively in their work. The following polynomial can be used...
Write bash shell scripts for the following problems and submit your answers a single. A )...
Write bash shell scripts for the following problems and submit your answers a single. A ) Write a linux bash shell script that reads your first and lastname as arguments and print them as shown below. In my example, I name the script as printname.sh. In the example, the two arguments follow the shell scriptname. Submit the script and output print screen. # sh ./printname.sh Abdullah Konak My first name is Abdullah My surname is Konak B ) Write a...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT