Narawa Games Narawa Games - 2 years ago 53
HTML Question

How do I include a custom input as part of a form?

I have an HTML form. All of the inputs are standard except for the slider. I made the slider out of

s instead of using
<input type="range">
, so I could add extra functionality and style it easier. How do I get the custom input to be part of the form?

I could've put together a query string and redirected the browser with JavaScript:

window.location = "/post?author=" + $("#name").val() + "&rating=" + document.elementFromPoint($("#slider-grabber").position().top + 20, $("#slider-grabber").position().left + 5).innerHTML + "&content=" + $("#content").val();

But that only works for a GET request, and my form sends a POST request.

Answer Source

Use an hidden input which you change its value according to what you did with your sliders.

<input type="hidden" id="slider_input" name="slider" value="" />

And then later in your JS / jQuery

    $('#slider_input').val(/* what you want */);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download