我正在尝试使用滑块显示/隐藏表格并同时更改屏幕上的数字,如下所示:
<input id="scaleSlider" type="range" value="1" min="1" max="9" step="1" onchange="showValue(this.value), showOrHide(this.value)"/>
<script type="text/javascript">
function showValue(newValue) {
document.getElementById("range").innerHTML = newValue;
}
</script>
<script type="text/javascript">
function showOrHide(newValue) {
if (("newValue").value = 1) {
document.getElementById(guest2).style.display="none";
document.getElementById(guest3).style.display="none";
document.getElementById(guest4).style.display="none";
document.getElementById(guest5).style.display="none";
document.getElementById(guest6).style.display="none";
document.getElementById(guest7).style.display="none";
document.getElementById(guest8).style.display="none";
document.getElementById(guest9).style.display="none";
}
if (("newValue").value = 2) {
document.getElementById(guest2).style.display="block";
document.getElementById(guest3).style.display="none";
document.getElementById(guest4).style.display="none";
document.getElementById(guest5).style.display="none";
document.getElementById(guest6).style.display="none";
document.getElementById(guest7).style.display="none";
document.getElementById(guest8).style.display="none";
document.getElementById(guest9).style.display="none";
}
}
</script>
“范围”设置得很好并显示数字,但我无法让表格切换”
我现在拥有的
<script type="text/javascript">
function showValue(newValue)
{
document.getElementById("range").innerHTML=newValue;
}
</script>
</td>
</table>
<script type="text/javascript">
function showOrHide(newValue){
if(newValue == 1) {
document.getElementById(guest2).style.display="none";
document.getElementById(guest3).style.display="none";
document.getElementById(guest4).style.display="none";
document.getElementById(guest5).style.display="none";
document.getElementById(guest6).style.display="none";
document.getElementById(guest7).style.display="none";
document.getElementById(guest8).style.display="none";
document.getElementById(guest9).style.display="none";
}
if(newValue == 2) {
document.getElementById(guest2).style.display="block";
document.getElementById(guest3).style.display="none";
document.getElementById(guest4).style.display="none";
document.getElementById(guest5).style.display="none";
document.getElementById(guest6).style.display="none";
document.getElementById(guest7).style.display="none";
document.getElementById(guest8).style.display="none";
document.getElementById(guest9).style.display="none";
}
}
</script>
仍然没有隐藏或显示。