Another rookie-question, which is rooted in a very shallow understanding of JS.
I'm building a small online multistep-form (made in a single html by hiding divs), where every button push is increasing a var with a fixed number:
JS:
var score = 20;
function updateScore (){
score = score + 10;
result.value = score;
}
I wish to display the score:
Using <input type="text" name="result" id="result" value="" size="" readonly>
I get the correct value (30).
However when I use <script>document.write(result)</script>
I get nothing and using <script>document.write(score)</script>
I get the original var (20).
Same problem when I want the var to output in a jquery progress-bar.
How can I make sure that it is the updated var, which displays in document.write?
EDIT: Complete JS
var currentLayer = 'lp';
var score = 10;
function showLayer(lyr){
hideLayer(currentLayer);
document.getElementById(lyr).style.visibility = 'visible';
document.getElementById(lyr).style.display = 'block';
currentLayer = lyr;
}
function hideLayer(lyr){
document.getElementById(lyr).style.visibility = 'hidden';
document.getElementById(lyr).style.display = 'none'
}
function goTo(lyr){
showLayer(lyr);
score = score + 10;
resultat.value = score;
}
function goToMinus(lyr){
showLayer(lyr);
score = score - 10;
resultat.value = score;
}
$(function() {
$( "#progressbar" ).progressbar({
value: score
});
});