Avatar of JAaron Anderson
JAaron Anderson
Flag for United States of America

asked on 

HowTo set a global variable in javascript or jQuery

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">


Open in new window


Avatar of undefined
Last Comment
Julian Hansen

8/22/2022 - Mon