I have a Javascript variable period being used in a function. I am unable to figure out how to use this same variable in other areas such as a document.write () function in part 2. I thought period was a global variable. What this entire page does, when I select a number in my list it hides the extra lines I don't need.
In part three, where I added var x = period, if I type document.write(period) it gives me the value I want. I just can't get that value anywhere else but that specific location. Basically, I need the report(this.value) value in my document.write() in part 2.
What I think is happening is report(this.value) doesn't report until a number is selected in my list so the HTML is written before I can use it. Not sure though.
I would really appreciate it if someone can help me with this. Thanks.
Also, Is there a better way to select a number in a list that I can use the variable anywhere. Thanks.
Part 1
<select size="1" id="Number" Name="Number1" onchange="report(this.value)">
<option value="" selected>How Many</option>
<option value="1">1</option><option value="2">2</option>
</select>
Part 2
<p id="1">
<script>document.write (x,")");</script>
Primary silkscreen layer
<img src="../0_Images/blank.jpg" width="60" height="15">
File name:
<input name="Primary Silkscreen12" type="text" size="60" style="border:3px solid #1871D1;" />
</p>
Part 3
function report(period) {
var x = period
if (period=="1") {
var i = 1;
do {
+ i;
i++;
var e = document.getElementById(i);
e.style.display = 'none'
} while (i < 34)
}
}
document.write(x,")");has no knowledge of thexin thereportfunction. You will have to appendx's value to the DOM from within thereportfunction.