javascript - Creating Command Interface Styled HTML Site

I have been working on building a website with some base functionality that I would be able to add on to later if needed.
I would like users to be able to enter text into the "Type here..." input box and when they press enter it add a new line on their site based on the command they just typed.
For example if they entered "help" it would pint a few new lines explaining what the site does and some beginning commands. My idea is to continue to add commands to there would need to be some scalability to this. I have the website + input box working how I want it to.
.headTag {
background-color: lightgrey;
display: inline-block;
width: 100%;
height: 26px;
}
.topPageTitle {
color: black;
font-size: 18px;
float: left;
background-color: lightgrey;
margin-top: 0px;
}
.mainPageText {
color: black;
font-size: 18px;
float: right;
margin-right:10px;
margin-top: 0px;
}
.userInput {
width: 100%;
position: absolute;
bottom: 10px;
}
.mainWindow {
margin-top: 24px;
font-family: typewriter;
font-size: 18px;
color: green;
width: 100%
}
.mainWindow p {
margin-top: -18px;
}
input[type=text] {
width: 100%;
border: none;
background-color: black;
font-size: 18px;
font-family: typewriter;
color: green;
outline: none !important;
}
@font-face {
font-family: typewriter;
src: url('../assets/typewriter.ttf');
}
body {
background-color: black;
font-family: typewriter;
color: lightgrey;
background:#000;
}
.easyMenu {
position: absolute;
bottom: 5px;
font-family: typewriter;
font-size: 18px;
width: 100%;
}
.easyMenu a {
color: lightgrey;
width: 24.5%;
display:inline-block;
}
.easyMenu a:hover {
color: black;
background-color: lightgrey;
}
<html>
<head>
<link rel="stylesheet" type="text/css" href="stylesheets/style.css">
</head>
<body>
<div class="headTag">
<p class="mainPageText">13.04.2020</p>
</div>
<div class="mainWindow">
<p>system>: Welcome to the Website.</p>
<p>system>: If you are stuck or don't know what to do type "Help"</p>
</div>
<div class="userInput">
<form>
<input type="text" autocomplete="off" spellcheck="false" id="fname" name="fname" value ="Type here..." onfocus="if(this.value==this.defaultValue)this.value=''" onblur="if(this.value=='')this.value=this.defaultValue">
</form>
</div>
<div class="easyMenu">
<a>>: Back</a>
<a>>: Create Private Chat</a>
<a>>: Join Private Chat</a>
<a>>: Information</a>
</div>
</body>
</html>
Answer
Solution:
You need to use Javascript to make it work: You need to use appendChild js command to make it work (https://www.w3schools.com/jsref/met_node_appendchild.asp)
[EDIT]
To resume what is said on the link, you should use the appendChild javaScript property that would allow you to add text on your page from the javascript code:
function getCommand(input){
if (input == "help"){
let p = document.createElement("p"); //creates a new <p> element
let text = document.createTextNode("Text you want to show");
p.appendChild(text); // adds the text to the paragraph
document.body.appendChild(p); // adds <p> to the body of your page
}
else {
let p = document.createElement("p"); //creates a new <p> element
let errorText = document.createTextNode("Invalid Command.");
p.appendChild(errorText); // adds errorText to the <p> element
document.body.appendChild(p);
}
}
Hope I helped you with my answer,
Romain.
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: method illuminate\database\eloquent\collection::paginate does not exist.
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.
About the technologies asked in this question
JavaScript
JavaScript is a multi-paradigm language that supports event-driven, functional, and mandatory (including object-oriented and prototype-based) programming types. Originally JavaScript was only used on the client side. JavaScript is now still used as a server-side programming language. To summarize, we can say that JavaScript is the language of the Internet.
https://www.javascript.com/
CSS
CSS (Cascading Style Sheets) is a formal language for describing the appearance of a document written using a markup language.
It is mainly used as a means of describing, decorating the appearance of web pages written using HTML and XHTML markup languages, but can also be applied to any XML documents, such as SVG or XUL.
https://www.w3.org/TR/CSS/#css
HTML
HTML (English "hyper text markup language" - hypertext markup language) is a special markup language that is used to create sites on the Internet.
Browsers understand html perfectly and can interpret it in an understandable way. In general, any page on the site is html-code, which the browser translates into a user-friendly form. By the way, the code of any page is available to everyone.
https://www.w3.org/html/
Welcome to programmierfrage.com
programmierfrage.com is a question and answer site for professional web developers, programming enthusiasts and website builders. Site created and operated by the community. Together with you, we create a free library of detailed answers to any question on programming, web development, website creation and website administration.
Get answers to specific questions
Ask about the real problem you are facing. Describe in detail what you are doing and what you want to achieve.
Help Others Solve Their Issues
Our goal is to create a strong community in which everyone will support each other. If you find a question and know the answer to it, help others with your knowledge.