1

this is the html code:

<form action='survey.php' method='post' class='mainForm'>
    <fieldset>
        <div class="widget first">
            <div class="head"><h5 class="iList">Text fields</h5></div>
                <div class="rowElem noborder"><label>Name:</label><div class="formRight"><input type="text" name="name"/></div><div class="fix"></div></div>
                <div class="rowElem noborder">
                    <label>Usual slider: </label>
                    <div class="formRight">
                        <div class="uiSliderInc"></div>
                    </div>
                    <div class="fix"></div>
                </div>
                <input type="submit" value="Submit form" class="greyishBtn submitForm" />
                <div class="fix"></div>

            </div>
        </fieldset>
    </form>

i have a slider with a range between 1 and 100 with this code:

<div class="uiSliderInc"></div>

in another file called "custom.js" i have this code:

$( ".uiSliderInc" ).slider({
    value:50,
    min: 0,
    max: 100,
    step: 1,
    slide: function( event, ui ) {
        $( "#amount" ).val( "$" + ui.value );
    }
});
$( "#amount" ).val( "$" + $( ".uiSliderInc" ).slider( "value" ) );

i wanna send the value of this slider once i press on the submit button to the same page so i can do some php things to it. i bought a theme complete with css and jquery code because i dont understand it but now i have to use it. so can anyone help me on how i send the value when i press the submit button?

Mihai Alexandru-Ionut
  • 47,092
  • 13
  • 101
  • 128
Munik
  • 151
  • 1
  • 1
  • 10

1 Answers1

1

You can use an hidden input

<fieldset>
    <div class="widget first">
        <div class="head"><h5 class="iList">Text fields</h5></div>
            <div class="rowElem noborder"><label>Name:</label><div class="formRight"><input type="text" name="name"/></div><div class="fix"></div></div>
            <div class="rowElem noborder">
                <label>Usual slider: </label>
                <div class="formRight">
                    <div class="uiSliderInc"></div>
                </div>
                <div class="fix"></div>
            </div>
            <input id="amount" type="hidden" name="amount"/>
            <input type="submit" value="Submit form" class="greyishBtn submitForm" />
            <div class="fix"></div>

        </div>
 </fieldset>

Then you can get value on server-side like this:

$amount= $_POST['amount'];

Custom.js

$( ".uiSliderInc" ).slider({
   value:50,
   min: 0,
   max: 100,
   step: 1,
   slide: function( event, ui ) {
      $( "#amount" ).val( "$" + ui.value );
   }
});
Mihai Alexandru-Ionut
  • 47,092
  • 13
  • 101
  • 128