I think I am missing a basic thing in my JS recently.
I’m trying to use a variable globally, but it doesn’t seem to be global.
I am defining it here, which is within the <HEAD> tags:
(I added the if null then declare just to ensure it wasn’t re-interpreted unexpectedly)
I have this function (extra irrelevant code snipped out):
Not surprisingly, the alert pops up with what I what I expect.
Then in my BODY I have added to a random line a test alert here:
This pops up with “file:///W:/SolidWorks/PDM/Drawings” AFTER the alert in the function has displayed the full path created.
This leads me to believe the drawingsfolder variable is not global?
I’m probably missing something basic here?
Steve (Delphi 2007 & XP)
I’m trying to use a variable globally, but it doesn’t seem to be global.
I am defining it here, which is within the <HEAD> tags:
Code:
<script type="text/javascript">
<!--
if (drawingsfolder == null){
var drawingsfolder = "file:///W:/SolidWorks/PDM/Drawings/";
}
var basefolder = "file:///W:/SolidWorks/PDM/Drawings/";
// -->
</script>
(I added the if null then declare just to ensure it wasn’t re-interpreted unexpectedly)
I have this function (extra irrelevant code snipped out):
Code:
<script type="text/javascript">
function SelType()
{
if (DWGtype.value==='Packing')
{
document.getElementById("secondLevel").innerHTML = "Not required";
document.form1a.secondSelect.options[0]=new Option("NULL", "NULL", true, false);
document.getElementById("thirdLevel").innerHTML = "Not required";
document.form1a.thirdSelect.options[0]=new Option("NULL", "NULL", true, false);
var drawingsfolder = basefolder + 'Packing/' + product.value;
alert("path set to: "+drawingsfolder);
}
}
</script>
Not surprisingly, the alert pops up with what I what I expect.
Then in my BODY I have added to a random line a test alert here:
Code:
<td width="40"><label><input name="ONEgroup" id="ONEradio1" value="True" onclick="nag(); changeRadio(this, 'ONE', true, 'green', 'black'); ONEcomments.value = ''; alert(drawingsfolder);" type="radio"></label></td>
This pops up with “file:///W:/SolidWorks/PDM/Drawings” AFTER the alert in the function has displayed the full path created.
This leads me to believe the drawingsfolder variable is not global?
I’m probably missing something basic here?
Steve (Delphi 2007 & XP)