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...
e.g.
top of page something like setting default state like so:
<script language="javascript">
var globalSessionValue="false";
</script>
... 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) {
globalSessionValue="true";
}
</script>
...
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 CONFIRMEDvar 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 } }</script><div id="LogicContainer"></div>