输入范围限制为每个表单一个

时间:2016-02-08 22:37:23

标签: javascript jquery html

我有一个表单,我需要三个输入范围供用户选择。

当我实现一个范围时,它的工作完全正常(见下文)但是当我添加第二个或第三个范围时,输出变量始终保持为0.

我如何向此表单添加两个范围?

我的表单如下:

<form action='search.php' method='post' oninput='amount.value=rangeInput.value'>

<input type='range' id='rangeInput' name='satscore' min='0' max='2400'>

<output name='amount' for='rangeInput'>0</output>

<input type='submit' value='FILTER'>

</form>

1 个答案:

答案 0 :(得分:1)

如果没有看到完整的代码,我想问题来自于如何命名范围和输入字段。这应该有效:

<form action='search.php' method='post' oninput='amount1.value=rangeInput1.value; amount2.value=rangeInput2.value; amount3.value=rangeInput3.value;'>

<input type='range' id='rangeInput1' name='satscore1' min='0' max='2400' value="0">
<output name='amount1' for='rangeInput'>0</output>

<input type='range' id='rangeInput2' name='satscore2' min='0' max='2400' value="0">
<output name='amount2' for='rangeInput'>0</output>

<input type='range' id='rangeInput3' name='satscore3' min='0' max='2400' value="0">
<output name='amount3' for='rangeInput'>0</output>

<input type='submit' value='FILTER'>

</form>