Friday 15 June 2012

Javascript Slider into PHP Variable -


The JavaScript below creates a slider inside the form that contains the submission code on the same page.

& lt; Div id = "outbox-bottom" & gt; Callback time selected & lt; Span style =

"font-size: 9px" & gt; (Pre-weekend): & lt; / Span & gt; & Lt; Span id = "callback_selected" & gt; & Lt; / Span & gt; & Lt; / Div & gt;

I need to get the time selected in a variable on the slider. I

$ time = $ _POST ['time'];
  & lt; Script type = "text / javascript" & gt; As can be used to get in my form. JQuery.noConflict (); JQuery (function () (jQuery ('# callback_selected') .HTML ("9 am") Select var = jQuery ("#callback"); var slider = jQuery ("& lt; div id = 'slider' & Gt; & lt; / div & gt; ") .interAfter (select) .slider ({min: 1, maximum: 12, category:" min ", value: 1, step: .5, slide: function Event, UI) {$ time_int = Ui.value; if (ui.value & lt; 5) {$ time_int = $ time_int + 8; if ($ time_int.toString (). Substr (-2) == '.5 ') $ Time_int = $ time_int.toString () .split ('. ') [0] + ": 30"; $ time_selected = $ time_in + "am";} and {$ time_int = $ time_int - 4; if ( $ Time_int.toString (). Substr () -2) == '.5') $ time_int = $ time_int.toString (). Partition ('.') [0] + ": 30"; $ time_selected = $ time_int + "Pm";} jQuery ('# Callback_selected') .HTML ($ time_selected);}}}}}); & lt; / Script & gt;    

Add hidden input to your form:

& lt; input type = "hidden" name = "time" id = "time" value = "" />

Then, once they have selected the time and you have to update the HTML #callback_selected , to update the value of hidden fields, the second Add This Price Will Post The Price.

  // The rest of your script ... jQuery ("# ​​time"). Val ($ time_selected);   

You should now be able to find the time value in your post.

No comments:

Post a Comment