Note that there are some explanatory texts on larger screens.

plurals
  1. POHiding the form once data saved in javascript
    primarykey
    data
    text
    <p>Hi I've done a lot of searching round but can't find anything concrete or that i can get working in my example. Was wondering if anyone could help. I've never used javascript before but have been asked for an assessment to code a piece of software to keep track of a score in a ten pin bowling game. I'm reading up as much as I can but there are a few things I'm still struggling on. I've made a form for the players to input their names and I want to be able to hide the form once they have inputted their names, thus making the interface look less cluttered. Have tried numerous methods but none seem to work for me, I've tried placing the form in a div and using an onClick event to hide the div but it doesn't seem to recognise the div etc, was looking for a few pointers, have taken my failed attempts out of the code to try and give a clear code for you to look at, thank you in advance </p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"&gt;&lt;/script&gt; &lt;script class="jsbin" src="http://ajax.aspnetcdn.com/ajax/jquery.templates/beta1/jquery.tmpl.min.js"&gt;&lt;/script&gt; &lt;meta charset=utf-8 /&gt; &lt;title&gt;JS Bin&lt;/title&gt; &lt;style&gt; article, aside, figure, footer, header, hgroup, menu, nav, section { display: block; } &lt;/style&gt; &lt;style id="jsbin-css"&gt; &lt;/style&gt; &lt;script&gt; function myFunction() { document.getElementById("formy").innerHTML="My First JavaScript Function"; } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;p id="formy"&gt;&lt;form&gt; &lt;h1&gt;Please enter player names!&lt;/h1&gt; &lt;input id="player1" type="text" placeholder="Player 1" /&gt; &lt;input id="player2" type="text" placeholder="Player 2" /&gt; &lt;input id="player3" type="text" placeholder="Player 3" /&gt; &lt;input id="player4" type="text" placeholder="Player 4" /&gt; &lt;input id="player5" type="text" placeholder="Player 5" /&gt; &lt;input id="player6" type="text" placeholder="Player 6" /&gt; &lt;input type="button" value="Save/Show" onclick="insert(),close.this", /&gt; &lt;/form&gt;&lt;/p&gt; &lt;div id="display"&gt;&lt;/div&gt; &lt;script&gt; var titles = []; var names = []; var tickets = []; var player1Input = document.getElementById("player1"); var player2Input = document.getElementById("player2"); var player3Input = document.getElementById("player3"); var player4Input = document.getElementById("player4"); var player5Input = document.getElementById("player5"); var player6Input = document.getElementById("player6"); var messageBox = document.getElementById("display"); function insert ( ) { titles.push( player1Input.value ); names.push( player2Input.value ); tickets.push( player3Input.value ); clearAndShow(); } function clearAndShow () { // Show our output messageBox.innerHTML = ""; messageBox.innerHTML += "&lt;td&gt;*" + player1Input.value + "&lt;br/&gt;&lt;td/&gt;"; messageBox.innerHTML += "*" + player2Input.value + "&lt;br/&gt;"; messageBox.innerHTML += "*" + player3Input.value +"&lt;br/&gt;"; messageBox.innerHTML += "*" + player4Input.value + "&lt;br/&gt;"; messageBox.innerHTML += "*" + player5Input.value + "&lt;br/&gt;"; messageBox.innerHTML += "*" + player6Input.value; // Clear fields titleInput.value = ""; nameInput.value = ""; ticketInput.value = ""; } &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload