another javascript newbie here.
I have been doing searches all week and have learned a lot but still can't get my script to work properly. My project is mixed PHP/Mysqli/Javascript but I am pretty new to Javascript.
I am trying to use a range slider to select a product then once one is chosen, several more range sliders become functional for selection of more details about that product then so on, so on,...
Plan A was to do something like change the opacity of the second trio of sliders until the main product is chosen but I have been stuck way too long just trying to get a mechanism to trigger the second step. I was hoping that using a simple If statement could do the trick but I can't seem so get anything outside of the function to see the argument values within it. I thought I understand Scope but what rules I have learned aren't working too hot in this case.
Here is a greatly-simplified script to get an idea of what I am doing:
<html>
<head>
<style>
input.prod_slider{
width:250px;
height:30px;
padding:10px;
background-color:gainsboro;
}
input.det_sliders{
width:250px;
height:30px;
padding:10px;
background-color:gray;
}
</style>
</head>
<body>
<input class='prod_slider' type='range' id='prod_choice' min='0' max='3' step='1' oninput='choiceSlide(value)'>
<p style='display:inline;' id='prod_777' >Use Slider To Choose A Product</p>
<!-This is the DIV I hoped to change the opacity on...>
<div id='detail_sliders'>
<input class='det_sliders'type='range' id='detail_0' min='0' max='3' step='1' ><br>
<input class='det_sliders'type='range' id='detail_1' min='0' max='3' step='1' ><br>
<input class='det_sliders'type='range' id='detail_2' min='0' max='3' step='1' ><br>
</div>
<div id='testDiv'></div>
<script>
var prodArr = ["product_1","product_2","product_3","product_4"];
var varNum1;
function choiceSlide(value_1){
key_1 = +value_1;
document.getElementById('prod_777').innerHTML = prodArr[key_1];
varNum1 = arguments[0];
return varNum1;
}
document.getElementById('testDiv').innerHTML = 'VarNum Value: ' + varNum1;
if (varNum1){
document.getElementById('detailSliders').style.opacity = '1';
}
else{
document.getElementById('detailSliders').style.opacity = '.5';
}
</script>
</body>
</html>
Simplified Version Number 2:
<html>
<body>
<input class='prod_slider' type='range' id='prod_choice' min='0' max='3' step='1' oninput='choiceSlide(value)'>
<p style='display:inline;' id='prod_777' >Use Slider To Choose A Product</p>
<div id='testDiv'>Test Div</div>
<script>
var prodArr = ["product_1","product_2","product_3","product_4"];
var varNum1;
function choiceSlide(value_1){
key_1 = +value_1;
document.getElementById('prod_777').innerHTML = prodArr[key_1];
varNum1 = arguments[0];
}
document.getElementById('testDiv').innerHTML = 'VarNum Value: ' + varNum1;
</script>
</body>
There may be better way to do this which I would love to hear about but I really would like to learn what I am doing wrong for use in the future. Thanks so much to any one who can help me. Thanks!!