Link to home
Start Free TrialLog in
Avatar of mrslate1
mrslate1

asked on

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.
Avatar of Scott Fell
Scott Fell
Flag of United States of America image

What on the html page determines the version?
> I asked this question on Stack Exchange and got beat to hell by those who answered.

That is why I am here!
> 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
fyi, I noticed an error on my code. I have updated to document.getElementById("demo").innerHTML =version;
Avatar of mrslate1
mrslate1

ASKER

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!
ASKER CERTIFIED SOLUTION
Avatar of Scott Fell
Scott Fell
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Scott, you are the greatest and you very very patient. Thank you brother!