Getting and retrieving text to div constantly

0 Ryan Shah · April 14, 2015
Hey everyone!

I am trying to make a program which, for individual countries, it will get a word which is typed in by the user through a text field.

I want to find an easy way to store this and constantly update and load this into a div without refreshing the page.

Does anyone have any ideas?

I was thinking it might be possible in AngularJS or JQuery or something but not sure.

Post a Reply


Oldest  Newest  Rating
+1 Jason Knight · April 14, 2015
Is this what you are after?

html elements

then get the value like and place it into a global var then your display element like so.
var countryEl = document.getElementById('user-country-el');
var displayEl = document.getElementById('display-el');
// set global variable val so it can be used out side the function where it is assigned.
var val = '';
// listen for key up and set variable
countryEl.addEventListener('keyup', function(){
var val = this.value;
displayEl.innerHTML = val;

If you need longer term storage ie, longer the the life of the page you will need to look into cookies and html5 local storage.

Having said this i recommend using a select tag for dealing with country input. 
which if you do decide to go that way here is a pre coded select list with all our earths magnificent countries

Hope this is what you where looking for and good luck! :)
0 Ryan Shah · April 15, 2015
Partially what I'm looking for thanks! But I need everyone who views the webpage to see these words
0 Jason Knight · April 15, 2015
Not a problem dude, sorry I only get on here late at night when the part of my brain that fully understands things has already called it a day..... 

Forgive me if I am wrong, but I am see this as you want people to type in there country and it gets added to a list of countries where every viewer can see that list? 

If this is the case you will have to collect the users input then post it back to your server where it is stored into a database that can be retrieved at a later point then displayed to every one who views your page.

To do this you'll need to use a language such as PHP or NodeJS to collect post variables to the server.
then a Database like MySql or MongoDB to store them.
  • 1



A scripting language that is added to standard HTML to create interactive effects, apps, games for the browser.