DONATE  
MENU
JSON
HTML
AJAX
JAVASCRIPT

JavaScript Tutorials

INTRODUCTION

» Introduction to JavaScript

» Practice IT Editor

» JavaScript Example

» JavaScript Placement

» JavaScript Syntax

» JavaScript Statements

» JavaScript Input

» JavaScript Output

» JavaScript Comments

» JavaScript Variables

» Variables' Scope

» JavaScript Operators

» JS Expressions & Concatenation

» JavaScript Data Type

» JavaScript Numbers

» Number Object

» JavaScript Strings

» String Object

» JavaScript Booleans

» Boolean Object

» JavaScript Functions

» JavaScript Arrays

» Array Object - Properties

» Array Object - Methods

» JavaScript Objects

» JavaScript Undefined

» JavaScript Nulls

CONDITIONAL TESTING

» If Statement

» If Else Statement

» JavaScript Ternary Operator

» Switch Statement

LOOPS

» For Loops

» While Loops

» Break & Continue

» For...In Loops

» do...while Loop

FUNCTIONS

» JavaScript Functions

» Creating Functions

» Functions' Parameters

» Functions' Arguments

» Function Invocation

» The Return Keyword

» The Arguments Object

» Callback Functions

» Arrow Functions

ARRAYS

» JavaScript Arrays

» Creating Arrays

» Accessing Arrays

» Looping Arrays

» Multi - dimensional Arrays

OBJECTS

» JavaScript Objects

» Creating Objects

» Prototype Definition

» Accessing Objects

» The this Keyword

AJAX

» Introduction to AJAX

JSON

» Introduction to JSON

JAVASCRIPT DATES

» The Date Object

» Date Methods

» Timing (SetInterval & SetTimeout)

MATH OBJECT

» Math Object

» Math Methods

HTML / JS DOM

» DOM Introduction

» Accessing HTML Elements in DOM

» Get And Change Elements' Contents & Values

» Change Styling - DOM CSS

» DOM Attributes

» JavaScript Event Listeners

» DOM Event Listeners

» JS Events

MISCELLANEOUS

» JS Strict Mode

» JavaScript Hoisting

» JavaScript let keyword

» Reserved Keywords

» JS Best Practices

» JavaScript vs ECMAScript

JAVASCRIPT EXAMPLES

» JavaScript Calculator

.. » JavaScript » Introduction » JavaScript Input
Share Tweet WhatsApp

JavaScript Input

Since JavaScript is the default scripting language of the web and can access all HTML elements, get their contents, get their values, change their contents, change their values, change their attributes and whatever that is inside of them, it is expected that you use HTML form elements in getting whatever inputs requiring processing on a webpage. Nevertheless, there exists some already defined (pre - defined) JavaScript functions that can help you get input values from a user easily and quickly. They are: Prompt() The JavaScript prompt() function is used in easily accepting a value from a web user for quick processing. In order to obtain the value, you call the function on a variable that thereafter stores the value for whatever processing. Example
<script>
var myVar = prompt("Enter a value:"); //Calling the prompt function on a variable(myVar)

alert("You entered: "+myVar);
</script>

Copy PRACTICE IT

For most of our examples on JavaScript requiring inputs' values, we shall be using this function. JavaScript Confirm() The JavaScript confirm() is a function that can be use in getting a web user's choice as regard an action that is about taking place. It is used in confirming a user's action. For example, asking a user if he/she wants to leave a page or not, delete an item or not, submit a form or not and etcetera. Just like the prompt() function, you call the confirm() on a variable so as to know what the user choice is. Example
<script>
var fdbk = confirm("Do you want to retry?");
if (fdbk == true){
alert("Process starting up");
}
else
{
alert("Bye");
}
</script>

Copy PRACTICE IT

SUMMARY
  1. In your web projects, you will most of the time use the various form elements(inputs, textarea, select) in getting inputs from a web user.
  2. But then, JavaScript have some pre defined functions that can easily be used in getting an input from the user.
  3. We have the prompt() function that can easily be used in getting just any value from a user.
  4. We also have the confirm() function that can be used in knowing whether a user wants to proceed with an action or not.
Take a short quiz on JavaScript Input.
Ask a question or tell us if JavaScript Input is easy or not.
cent?

Join our 1,090 subscribers to receive tutorials' updates!

  We won't spam your mail box. We hate it.





StackBeginner 2021 © Joseph Omamode