Question

Javascript question: Create an array with 4 elements in it. Make that array appear on the...

Javascript question: Create an array with 4 elements in it. Make that array appear on the screen in the form of a list by using innerHTML. Add a form that will allow users to add a new item to the array. After the user submits their item, it should appear on the page with the other array items.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <ul id="list">

    </ul>
    <form onsubmit="return addItem();">
        Enter item: <input id="inputBox" type="text"/>
        <button>Add word</button>
    </form>
<script>
    function addItem() {
        var word = document.getElementById('inputBox').value;
        var elem = document.createElement('li');
        var textNode = document.createTextNode(word);
        elem.appendChild(textNode);
        document.getElementById('list').appendChild(elem);
        document.getElementById('inputBox').value = '';
        return false;
    }
</script>
</body>
</html>

hello how are vou Enter item Add word

Add a comment
Know the answer?
Add Answer to:
Javascript question: Create an array with 4 elements in it. Make that array appear on the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • JAVASCRIPT Create a simple web page that contains a JavaScript form that will allow the user...

    JAVASCRIPT Create a simple web page that contains a JavaScript form that will allow the user to answer 7 trivia questions. Your trivia game should contain: 2 text boxes 2 select dropdowns 2 multiple choice questions (using radio buttons, 4 options min) 1 choose-all-that-apply (checkboxes, 4 options min, one answer should be "None of the above"). No part-points for semi-correct answers. The questions can cover any topic you wish - but please keep it professional and easy enough that the...

  • JavaScript (Please debug this code) When a user enters a string in the input box, the...

    JavaScript (Please debug this code) When a user enters a string in the input box, the program is designed to add the string to an array. When the array reaches a certain length, the program displays all the users' entries in a list on the page. When you finish debugging, the user's entry in the input box should be cleared each time the submit button is clicked. Additionally, after five strings are submitted, the entire list of submitted strings should...

  • 5. ///////////////////////////////////////////////// Using javascript Create a paragraph on your page that says “This isn’t even my...

    5. ///////////////////////////////////////////////// Using javascript Create a paragraph on your page that says “This isn’t even my final form!” ( This isn’t even my final form! ). Add a JS mouseover event to that paragraph. When the paragraph has a mouse hovering over it, the text inside should change to “This is my second form!” ( This is my second form! ). Add one more event handler so that when that paragraph is double-clicked, the text will say “THIS is my...

  • Use html form and external javascript for this. and add css for innovation. a.   Signup page...

    Use html form and external javascript for this. and add css for innovation. a.   Signup page – for users to signup to the website i.   When the user clicks on the submit button, they must see a confirmation alert have signed up. ii.   Use a form with six input boxes to allow the user to signup b.   Login page – for users to login to the website iii.Use a form with two or more input boxes c. after login user...

  • c++ can use if else, loop,function ,array,file i.o. Can not use swtich, global variables etc..   Please...

    c++ can use if else, loop,function ,array,file i.o. Can not use swtich, global variables etc..   Please do all parts. previously I post 3 time for part1 ,2 and 3 but I can't make it into one complete program code. I even try to post a questions ask and post the 3 parts of code for experts to put it together. But experts said it's not enough information. please help... Thank you ! Program Objectives: Allow students to create arrays Allow...

  • JAVASCRIPT Create a program that uses a loop, conditional statements, and a function to complete the...

    JAVASCRIPT Create a program that uses a loop, conditional statements, and a function to complete the following: Using a loop, ask the user to enter the item name, price, and quantity for 3 items. Using a function, calculate the following: Calculate the cost of each item and display the cost on the screen. Calculate the total cost of the three items and display the total cost on the screen. Add a shipping charge at the end of the order based...

  • In Java: Create an array of Integers with 10 elements, loop (use a for loop) through...

    In Java: Create an array of Integers with 10 elements, loop (use a for loop) through the array of integers printing their values to the screen. Create an array of Strings with 10 elements, loop (use a for loop) through the array of Strings printing their values to the screen. Finally, create an ArrayList of Integers. Use the loop from part 1 above and add each integer as you print it to the ArrayList as well, then start a final...

  • Write a JavaScript program that will do the following: Create an array of size 50. Store randoml...

    Write a JavaScript program that will do the following: Create an array of size 50. Store randomly generated number (between 0 and 10) into this array. Ask users what number they want to search in the array. Make sure user given number is between 0 and 10. Search the user given number in the array: If the program found the number in the array then display all the indexes where the number was found. If the program does not find...

  • <!DOCTYPE html> <html> <head> <!-- JavaScript 6th Edition Chapter 4 Hands-on Project 4-3 Author: Da...

    <!DOCTYPE html> <html> <head> <!-- JavaScript 6th Edition Chapter 4 Hands-on Project 4-3 Author: Date:    Filename: index.htm --> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Hands-on Project 4-3</title> <link rel="stylesheet" href="styles.css" /> <script src="modernizr.custom.05819.js"></script> </head> <body> <header> <h1> Hands-on Project 4-3 </h1> </header> <article> <div id="results"> <p id="resultsExpl"></p> <ul> <li id="item1"></li> <li id="item2"></li> <li id="item3"></li> <li id="item4"></li> <li id="item5"></li> </ul> </div> <form> <fieldset> <label for="placeBox" id="placeLabel"> Type the name of a place, then click Submit: </label> <input type="text" id="placeBox"...

  • Write a program that will create an array of ten integers, allow the user to enter...

    Write a program that will create an array of ten integers, allow the user to enter those integers, and eventually search through the array based on index position: 1. Declare the array. You cannot assign elements to an array until it has first been created. 2. Next, run a for loop so that the user can enter an integer to save in each index position of the array. Since you this array holds ten elements , the index position starts...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT