How to display One of Three lines of text on HTML page depending on user version.

I am developing a around 300 HTML web pages that need a version number displayed in the footer. Problem is some customers are using version A and some people are using version B. So depending on the user, I want to display A or B and only want to change it in one place. I have used document.write and pointed to a .js named ver.js file which contains

document.write('Test: V4.5')

Open in new window



and the HTML to display on the page:
<script language="javascript" type="text/javascript" src="ver.js"></script> 

Open in new window


My question is, if I have three different versions I need to display depending on the user, what is the best method to display ('Test: V4.5') or ('Test: V4.6') or ('Test: V4.7') using  JavaScript which would be written in one place. I don't want to have to hand write the version number on each page, but only in one spot. I asked this question on Stack Exchange and got beat to hell by those who answered. Can you guys help? I am trying to learn this and hope I am asking this question the right way.

Further, lets say user ONE should see Version 4.5 on the bottom of their page, and user TWO should see Version 4.8 at the bottom of the page. And since I have 300 pages, I only want to change the version in one place to be reflected on all 300 pages?

I know I can use Variables, but not sure the correct way to do this. I am not using PHP.

Thank you for not yelling at me.
mrslate1Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
What on the html page determines the version?
0
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
> I asked this question on Stack Exchange and got beat to hell by those who answered.

That is why I am here!
5
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
> document.write('Test: V4.5')

At the start of your js code you could do something like

var version = 'Test: V4.5';

Then in place of document.write('Test: V4.5') use document.write(version). And in the area you want to update on your site
var version ='Test: V4.5';
document.getElementById("demo").innerHTML = version ;

Open in new window

 <div id="demo"></div>

Open in new window

http://jsbin.com/kiyufezaya/edit?html,js,output
1
Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
fyi, I noticed an error on my code. I have updated to document.getElementById("demo").innerHTML =version;
0
mrslate1Author Commented:
Thank you Scott! There is one caveat,   that would be three version numbers that might be used on all the pages. That is if a person is using version 1 of the web app, then version 1 would be displayed in the footer and we only want to have to update one file to affect all pages. Version 2 users would see Version 2. Should I be using some sort of variable within the JavaScript where my as the developer would only need to update in one spot? There isn't anything on the page that would determine the version of the web app except for the number itself.

In other words, do I need three different .js files one that has
var version ='Test: V4.5';
document.getElementById("demo").innerHTML =version;

Open in new window

One that says
var version ='Test: V4.4';
document.getElementById("demo").innerHTML =version;

Open in new window

and one that says
var version ='Test: V4.5';
document.getElementById("demo").innerHTML =version;

Open in new window

and point to the correct version by using
<div id="demo1"> 

Open in new window

or
<div id="demo2">

Open in new window

and so on? Sorry for the request for clairification. I want to do this the correct way and I really appreciate your help!
0
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
What you would want to do is create some type of text file to load and use that. A json or jsonp (if using across different domains).  Then the json file can contain not only the version, but any other fields you want to add.

Using jquery it would be something like this

$(function(){ // on load, load this code

var url = "SiteSetUp.json";  //location of your json file


            jQuery.ajax({  //http://api.jquery.com/jquery.ajax/
                url: url,
                type: 'GET',
                dataType: 'json',
                success: function(response) {

                    createSiteContent(response);

                },
                error: function(response) {
                    console.log('error');
                },
            });
});

function createSiteContent(response){
   var version =  response.sitesetup[0].properties.version;
   var logo=  response.sitesetup[0].properties.logo;
  
   $('#version').html(version);
}

Open in new window


<div id="version"></div>

Open in new window


Your json file can look like this
{
	"sitesetup": [{
		"properties": {
			"version": "Test: V4.5",
			"background": "#FF0000",
			"text": "#000000",
			"logo": "/images/logoblue.png",
			"phone": "555-555-1212"
		}
	}]
}

Open in new window


The idea is you can set up multiple items with this json file. Just load the one file and that can update the site content as needed.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mrslate1Author Commented:
Scott, you are the greatest and you very very patient. Thank you brother!
4
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JScript

From novice to tech pro — start learning today.