programmierfrage.com
Ask a question    Sign Up Sign In
  • Train typing speed
  • About/Contact
  • Privacy Policy
  1. Home
  2. javascript - Creating Command Interface Styled HTML Site

269 votes
1 answers

javascript - Creating Command Interface Styled HTML Site

Get the solution ↓↓↓

I have been working on building a website with some base functionality that I would be able to add on to later if needed.

Sample Website

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>

Undefined asked
2021-12-6
Write your answer



207
votes

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.

Write your answer




Share solution ↓

Additional Information:

Date the issue was resolved:
2021-12-6
Link To Source
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.

Ask a Question

Similar questions

Find the answer in similar questions on our website.

845 javascript - $.ajax post loads html code from current page instead of requested php
533 javascript - How can i make a sticky sidebar for a wordpress site?
533 javascript - How to create HTML only if condition is true
944 javascript - Malicious code found on client's website
880 html - php simple_html_dom select correct table data
372 php - How to submit a form to external website to get an XML response but display response on your website
944 javascript - How to properly declare a php function as a variable in another function
709 php - Interface laravel doesn't bind why?
458 php - RuntimeException when executing SubRequest in command line
608 php - Calling JavaScript function before and after ajax request in yii ajaxSubmitButton

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.

Yacht Magazine



Latest questions:

614 javascript - jQuery post() to php page

499 smtp - PHP Mail sent from localhost to server

616 php - Unrecognized field: user_name, while querying Via Doctrine using ZF2

942 php - How to write parameters in url?

730 php - Failed to set unsafe attribute

31 PHP and mysql integration with apache tomcat 6 in linux

776 php - S3 signed url not working through form submit

235 php - How to display message when Java applet fails to load?

304 php - Default text must disappear in textarea upon click using jQuery

438 php - the better method to store page hits in crowded site

Users questions:

NEW

mysql

NEW

Warning: Undefined array key "program" in E:\xampp\htdocs\pi\alumni.php on line 27 Warning: Undefined array key "enter_course" in E:\xampp\htdocs\pi\alumni.php on line 31 Warning: Undefined array key "enter_address" in E:\xampp\htdocs\pi\alumni.php on line 32

NEW

Rename existing images with keyword in WordPress PHP

NEW

codeigniter

NEW

Class "web_profiler.controller.profiler" does not exist after upgrading symfony 3.4 to 4.4 version




PHP x 410847
Laravel x 36785
Yii x 3846
CodeIgniter x 9997
Symfony x 7793
CakePHP x 3085
Zend Framework x 1235
Phalcon x 300
FuelPHP x 47
Slim x 570
JavaScript x 36883
React x 550
Angular x 1121
Vue.js x 181
JQuery x 11108
Backbone.js x 21
Node.js x 463
Ember.js x 10
Meteor x 7
Polymer x 20
Aurelia x 1
MySQL x 39074
CSS x 2497
Bootstrap x 1603
Foundation x 84
UIkit x 4
Semantic UI x 2
Bulma x 2
Animate.css x 1
HTML x 20978




© 2021-2023 Programming problem solving site for beginners and advanced. Answers to questions related to coding.

E-mail: [email protected]

This site uses cookies. We use them to improve the performance of our website and your interaction with it. Confirm your consent by clicking OK


OK