Question

HTML and Java script Is there a way to delete an element of an array? For...

HTML and Java script

Is there a way to delete an element of an array?

For example when I click this first button then a random word will appear then when I click this second button then the randomized word will be deleted or removed from the array.

here is the portion of the code

<button class="wew" onclick="thesisFinal()"><i class="fa fa-play-circle"> Start</i></button></div>  
           <button class="wew" onclick="removeThesis()"><i class="fa fa-play-circle"> Start</i></button></div>  
           <p id="thesisget">Click to generate</p>

          
       </div>
   </div>

   <script>
       var thesis=["car","waybipt","wew","aioweaio","awuiegauega","aiowehauiehauiw","aopwiheioaheauiowhe","cajicnajcnancan","papapaappapa"]

       function thesisFinal(){
           var randomThesis=Math.floor(Math.random()*(thesis.length));
           document.getElementById('thesisget').innerHTML=thesis[randomThesis];
       }
       function removeThesis(){
          

       }
   </script>

Homework Answers

Answer #1

Dear Student ,

As per the requirement submitted above , kindly find the below solution.

Here a new web page with name "thesis.html" is created, which contains following code.

thesis.html :

<!DOCTYPE html>

<html lang="en">

<head>

<title></title>

<meta charset="UTF-8">

<meta name="viewport" content="width=device-width, initial-scale=1">

</head>

<body>

<button class="wew" onclick="thesisFinal()"><i class="fa fa-play-circle"> Start</i></button></div>

<button class="wew" onclick="removeThesis()"><i class="fa fa-play-circle"> Remove</i></button></div>

<p id="thesisget">Click to generate</p>

</div>

</div>

<script>

//array

var thesis=["car","waybipt","wew","aioweaio","awuiegauega","aiowehauiehauiw","aopwiheioaheauiowhe","cajicnajcnancan","papapaappapa"]

//display random element from the array

function thesisFinal(){

var randomThesis=Math.floor(Math.random()*(thesis.length));

document.getElementById('thesisget').innerHTML=thesis[randomThesis];

}

//function to remove array element

function removeThesis(){

//generate random number to delete array element

var removeThesis=Math.floor(Math.random()*(thesis.length));

//display element

document.getElementById('thesisget').innerHTML=thesis[removeThesis];

//remove array element from the array

thesis.splice(removeThesis,1);

}

</script>

</body>

</html>

======================================================

Output : Open web page thesis.html in the browser and will get the screen as shown below

Screen 1 :thesis.html

Screen 2:Screen when start button is clicked

Screen 3:Screen when remove button is clicked

NOTE : PLEASE FEEL FREE TO PROVIDE FEEDBACK ABOUT THE SOLUTION.

Know the answer?
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
Similar Questions
Hello, I am trying to create a java script code that can arranges the input lowest,...
Hello, I am trying to create a java script code that can arranges the input lowest, highest, finding average, sort them and the clear form functionality. I managed to create the code that sorts the number input from lowest to highest but I am stuck on the rest. See the code below Please help. <!DOCTYPE> <html> <head> <title>EXAM01_01</title> <style type="text/css"> form{color:black;background-color:lightgray;border:6px solid black;border-width:4px;width:450px;margin:1px;padding:1px;} #ans1,#ans2,#ans3,#ans4,#numbers{background-color:white;border:4px solid black;} input[type="button"]{color:black;background-color:red;border:4px solid black;} input[type="text"]{margin:2px;} div.title{color:white;background-color:black;float: left; width: 450px; text-align:center;} </style> <script>    function readNumbers()...
I have created images that I would like to have placed where the message is revealed?...
I have created images that I would like to have placed where the message is revealed? What is the best way to make it work. I tried to make it work and have not had much success. My images are saved as png's. Here is my original code. <!Doctype html> <html> <head> <meta charset="UTF-8"> <title>Dice Game</title> <link rel="stylesheet" type="text/css" href="demo.css"> </head> <body> <div class="row" align="center"> <div class="col-4"> <h3>Your Dice</h3> <img src="images/d1.png" width="100" height="100" alt="roll: 1" id="mydice1"> <img src="images/d1.png" width="100" height="100"...
Java Script I need the code to produce these 3 output. I can only get it...
Java Script I need the code to produce these 3 output. I can only get it to produce input #3 I need it to produce the following: // Input #1: // http://www.example.com // Output // http://www.example.com // Input #2: // http://www.example.com?name=r2d2 // Output // http://www.example.com // name: r2d2 // Input #3: // http://www.example.com?name=r2d2&email=r2d2%40me.com&human=no // Output // http://www.example.com // name: r2d2 // email: [email protected] // human: no THIS IS WHAT I HAVE SO FAR: HTML <!DOCTYPE html> <html lang="en"> <head> <meta...
The following code shows the head and body sections in an HTML file: <head> <script> function...
The following code shows the head and body sections in an HTML file: <head> <script> function init() { var x, y, z; z = document.getElementById("abc").innerHTML; y = "B"; x = "C"; document.getElementById("abc").innerHTML = x+y+z; } </script> </head> <body onload="init();"> <p id="abc">A</p> </body> What would be displayed on the browser when the above webpage is opened? BC CB or CBA or A or ABC
Need HTML and JS code. Write a Javascript function named RandomString(randomStringLength) that returns a string filled...
Need HTML and JS code. Write a Javascript function named RandomString(randomStringLength) that returns a string filled with random characters where the length of the random string is defined by the input parameter. HINT: Use a for-loop, Math.random, and the fact that the alphabet has 26 characters (remembering that we can have both lower-case and upper-case characters in a string). This is what I have: <html> <!-- inputbox.html Jerry Davis --> <!-- Web page that sets the correct letter value. -->...
Please linked both files. For this assignment you need to create a ToDo list using Javascript,...
Please linked both files. For this assignment you need to create a ToDo list using Javascript, along with HTML and CSS. Begin by creating a HTML page called todo.html. Then create a Javascript file called todo.js and link it in to the HTML page using a script tag. All Javascript for the assignment must be in the separate file. (For CSS, feel free to include styles in a style block at the top of the HTML page, or to link...
*To the guy who answered last time. You're not following the directions. Please follow specific directions...
*To the guy who answered last time. You're not following the directions. Please follow specific directions below.* Create a "web page" with the following components: An input field for the "number of rounds to play" The "number of remaining" rounds should also be displayed somewhere on the screen. A button to "Start" the game play. The function attached to this button can "setup" the rest of the game. For example: initialize counters, show/hide other components, etc. A set of buttons...
<!doctype html> <html lang=”en”>   <head>     <title>Principal Calculation Form</title>     <meta charset="utf-8"/>         
<!doctype html> <html lang=”en”>   <head>     <title>Principal Calculation Form</title>     <meta charset="utf-8"/>                   <script src="code.js"></script>   </head>      <body onload="setFocus();">     <div class="container">                                       <div class="main">                                                                                <form action="#" method="post" name="form_name" id="form_id" class="form_class" >                                                                           <h2>--Principal Loan Form--</h2>                                                                                                                                                      <h5>Disclaimer: This software by no mean will precisely predict your mortgage through your lender company.  This Software will only assume the four items below in order to make an educated guess or prediction to your exact mortgage interests amount and the duration of your loan from your lender. <img...
This will be my third time submitting this question. THERE SHOULD BE NO USE OF CSS...
This will be my third time submitting this question. THERE SHOULD BE NO USE OF CSS OR SWITCH STATEMENTS IN THE JAVASCRIPT. Even though there is stylesheet in the HTML file do no create a new one. Project Standards: Students will use click events to capture user input. Students will use variables to store information needed by their application and keep track of their program’s state. Students will use conditionals to control project flow. Project Task You will be building...
Hi, there. A question about web development. I'm using the jquery to try the reset method...
Hi, there. A question about web development. I'm using the jquery to try the reset method in an input form in the PHP file but it didn't work. Here is a part of my code. <div id='signbox' class='modal-window'> <form id= 'signF' method='post' action='centerControl.php'> ... <input id='resetSign' type='button' value ='Reset'>; ... </form> </div> <script> $(document).ready(function(){ $("#resetSign").click(function(){ $("#signF")[0].reset() }); }); </script> And one more question that I'm a new player so what kind of tool I can check all my jquery PHP...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT