How to get user input in JavaScript [closed] - javascript

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I am new to Javascript.
I want to know how to get user input in javascript,i.e. like we have
scanf or cin in C/C++, how to take in user input in JS?
I am using Atom editor in Mac, and i have tried readline() and compiler says undefined.
Please help!!

Create an input tag with id attribute:
<input type="text" id="myid" name="myname" />
Then, in Javascript, you can get the value of an input, for example, using its id:
var myvar = document.getElementById('myid').value;

Related

How to display data in select box using angularJS? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
Hi I want to bind the zipcode's in the select box from the following data.
How to do that ??
[[{'zipcode':'6451105'},{'zipcode':'641515'},{'zipcode':'564555'}]]
Assuming you want to bind one of your zipcode objects to a property, eg
{zipcode: '641515'}
and your actual data looks like this
[{'zipcode':'6451105'},{'zipcode':'641515'},{'zipcode':'564555'}]
this should suffice
<select name="zipCode" ng-model="zipCode"
ng-options="zipCode.zipcode for zipCode in zipCodes"></select>
http://plnkr.co/edit/rY0cFVqyZHVoB4DyZj1Z?p=preview

How to take html script from text form and execute it in a new window? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I am trying to make HTML and JavaScript executor but I don't know how to take text from text form and execute it in a new window. Like in w3schools.
They way w3schools does it is they POST the data from the text frame and then in the second frame, it runs the page as a document.
On clicking submit, you could then change the contentWindow.document value to equal the HTML that the user entered

Java script code to show current date only in an input box of a HTML page [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
Java script code to show only current date(not time) in an input field of a HTML page.
Your question is in part, answered here:
How do I get the current date in JavaScript?
From here you simply have to set the current value of a given input field, let's say it's ID is 'date'.
document.getElementById('date').value = dateVariable;

How to set title page with angular js [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have a situation where the client will set the name that will appear in the <title> of the page.
Wanted to know how best to do this with AngularJS.
It will define and save thus leaving the <title> Custom.
Just add ng-model in your input
<input type="text" ng-model="title">
This one in your controller
document.title = $scope.title;

Changing form input field types with Javascript [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I frequently find myself opening up Web Inspector in Safari when registering on a website and then changing the password field to a text field so I can view the text entered and don't have those black dots that cover up the password.
Opening Web Inspector time and time again is bit of a hassle so I wondered if it wouldn't be possible to use a piece of JS code in my bookmark bar and when I click it, the javascript changes every form input field with type="password" to type="text"
Tried some things I found on the web, but they didn't really work…
try this
document.querySelector("[type=password]").setAttribute("type","text");

Categories