troubleshooting Question

HowTo set a global variable in javascript or jQuery

Avatar of JAaron Anderson
JAaron AndersonFlag for United States of America asked on
4 Comments1 Solution2146 ViewsLast Modified:
hi all, Ive read alot on the web that simply doesnt make sense on this hoping to have a clear simple discussion on how to handle a string and perform comparison against it along the open session...

top of page something like setting default state like so:
<script language="javascript">
var globalSessionValue="false";
... then many MANY lines later a later function changes the value of the string like so:
<script language="javascript">
function whatever(){
if ( getElementbyID("WhateveruserEvent").value ... whatever comparison here <= === ! > 0) {
so this way later I can perform another simple if/else on the changed state
<script type="text/javascript">
function evaluateRestriction(){ // this has tested to fire On TAB into the field CONFIRMED
var checkState = globalSessionValue.value; 
		if ( globalSessionValue.length > 4) { //false
			document.getElementById("LogicContainer").innerHTML = "<img src='SHOW GOOD PHOTO' />";
		} else { 
			document.getElementById("LogicContainer").innerHTML = ""; // DONT SHOW anything here


<div id="LogicContainer">

Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros