Hi everybody! I'm new to this forum and full of hope to solve this issue.
Please help out if you can!
So, I have slider on page that goes from 0 to 100. and I need to pass the value that visitor selected to the next page by using submit button.
Here is javascript code that I have for the slider.
-----------------------------------------------
<script type="text/javascript">
window.addEvent('domready', function(){
var slider1 = new Slider('slideContainer1', 'slideHandle1',{onComplete: function(val){$('pos1').setHTML(val);}});
var slider2 = new Slider('slideContainer2', 'slideHandle2', {
onTick: function(pos){
this.knob.effect(this.p, {duration: 200, transition: Fx.Transitions.quadOut}).start(pos);
},
onComplete: function(val){
$('pos2').setHTML(val);
},
steps: 5
});
});
function SetJsValue()
----------------------------------------------
Next page will catch value by $_post or $_get. I guess.
Please if you have any ideas let me know.
I'm new to javascript and would really appreciate your help.
If you've got a form with submit button passing your variables to the next page with GET or SEND, the easiest way to pass the variable from js to php is just to have your script change the value of a hidden input in the form before it submits that way you can grab it on the next page.
Or if your slider is an input element inside the form already you should be able to grab that as long as it's been named.
Hi
I tried many ways to pass variables,
IT WILL NEVER WORK IN A ONE CODE
JavaScript runs on the BROWSERS machine,
PHP runs on the SERVER
so it will NOT work!
you CAN use PHP to build the J.S script using echo command,
echo '<script> function XXX(); {
do this'. $php_variable1.'
do that'. $php_variable2.'
}' ;
but passing JavaScript Variables to PHP is possible ONLY using a FORM as written before.
Bookmarks