简体   繁体   中英

Setting input value when moving 'scroll control'

I've been working on a script that lets a user set a setting using HTML5' <input type="range" , I've got it to work and got it to show a value on my site, but the thing is that I want the user set setting to be posted as a form input $_POST['gearsdrag'] .

For clearification I'm providing a JSfiddle.

http://jsfiddle.net/hqdesf70/

The input I want to be sent is <input id="r" type="text" name="gearsdrag" value="6000" />

But what the script set's is <input id="r" type="text" name="gearsdrag" />6000</input> and that's not being sent with $_POST .So is there a way to do this or maybe with get parameters or something.I can't figure it out.

Changing the function to this will insert the value into the input and from there you can post it is that what your after?

<script>function showValue(newValue)
{
    //changing the "innerHTML" to "value" is what inserts it into the text field

    document.getElementById("r").value = newValue;
    document.getElementById("rr").innerHTML = newValue;
}

</script>
Keisti pavarą prie: <span id="rr">0</span> / RPM
<form action="test.php" method="post">
    <input type="range" min="0" max="7800" value="0" step="100" onchange="showValue(this.value)" />
    <input id="r" type="text" name="gearsdrag" value=""/>
    <input type="submit" value="Nustatyti" />
</form>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM