Jump to content

gazzamc

Members
  • Posts

    13
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

gazzamc's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. ok well thanks for all the help.. much appreciated..
  2. i dnt no if you were waiting for a notification on this but i edited the post above.. didn't want to double post.. and sorry for doing it now..
  3. ok tnx i'll install firebug and do that... Edit : OMG it worked.. tnx so much.... now how can i change the numbers from 1 - 100 to something else like 1 - 1000 or something... tnx again.
  4. ok here it is.. <?php if (isset($_POST['slider'])) { $ptz = $_POST['slider']; /// Grabs user input. $prce = 500; $points = 2000; // Sets discount. $price = $prce; $dis = '0.01'; $price2 = $price * $dis; // gets discount from price // sets percentage per x amount of ptz. $pts = $ptz; $perc1 = '100'; // above 1% = 100 ptz $total = $pts / $perc1; // users ptz divided by 100 ptz $mtotal = $price2 * $total; // discount multiplied by result above. // Subtracts discount from price. $ftotal = $price - $mtotal; $arr = array( "Points" => $points, "Price" => $prce, "Discount" => $ftotal ); @header("Content-type: application/json"); echo json_encode($arr); } ?> <!DOCTYPE html> <html> <head> <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.3/themes/base/jquery-ui.css" type="text/css" /> </head> <body> <div id="foo">Data returned from php will show here.</div> <div id="scrollbar"></div> </body> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/jquery-ui.min.js"></script> <script type="text/javascript"> $(document).ready(function() { $('#scrollbar').slider({ value: 0, slide: function(event, ui) { $('#scrollbar').slider('value', ui.value); $.ajax({ type: 'post', url: '#', datatype: 'json', data: {'slider': ui.value}, success: function(fromphp) { $('#foo').html("Points = " + fromphp.Points + "<br />Price = " + fromphp.Price + "<br />Discount Price = " + fromphp.Discount + "<br />"); } }); } }); }); </script> </html>
  5. ok i tried it and i took 2 screens... There is no change on move.. [attachment deleted by admin]
  6. To be honest i don't , sorry. so in the last example if i just split them up into two file it will work? I'm not sure you understand what Ajax is. In this example, data is sent via Javascript back to the server to php, php then does some calculations and sends the data back to Javascript, Javascript then displays the results. No. Have you looked at the last example I have posted? Its does what your after.
  7. I know what i want.. i want the value from the slider to be put into the variable $ptz.. then i want php to do the math and output the results... if i put it into a separate file would i need to refresh the page.. i want to achieve this without refreshing the page.. Thanks..
  8. ok i'll give that a try... EDIT: After doing that the slider shows no output only "Data returned from php will show here."
  9. Here it is... using your first complete example.. <?php if (isset($_POST['slider'])) { $ptz = $_POST['slider']; } else { ?> <!DOCTYPE html> <html> <head> <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.3/themes/base/jquery-ui.css" type="text/css" /> </head> <body> <div id="foo">Data returned from php will show here.</div> <div id="scrollbar"></div> </body> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/jquery-ui.min.js"></script> <script type="text/javascript"> $(document).ready(function() { $('#scrollbar').slider({ value: 0, slide: function(event, ui) { $('#scrollbar').slider('value', ui.value); $.ajax({ type: 'post', url: '#', datatype: 'json', data: {'slider': ui.value}, success: function(fromphp) { $('#foo').html(fromphp.data); } }); } }); }); </script> </html> <?php } ?> <?php /// Grabs user input. $prce = 500; $points = 2000; // Sets discount. $price = $prce; $dis = '0.01'; $price2 = $price * $dis; // gets discount from price // sets percentage per x amount of ptz. $pts = $ptz; $perc1 = '100'; // above 1% = 100 ptz $total = $pts / $perc1; // users ptz divided by 100 ptz $mtotal = $price2 * $total; // discount multiplied by result above. // Subtracts discount from price. $ftotal = $price - $mtotal; echo "Points = ".$points."<br />"; echo "Price = ".$prce."<br />"; echo "Discount Price = ".$ftotal."<br />"; ?>
  10. ok i've tried that but when i try to use the variable i get a php error. unknown variable.. but i'll keep trying...
  11. i couldn't find a way to edit my post... but anyway how do i put that number from the slider into the php variable?? (from the first complete code u posted). Thanks..
  12. all i can say is thank god you got bored lol ... Thanks so much for this... Do you know of any tutorials that i can look at to understand AJAX more??? Thanks again...
  13. Hey guys i need some help on this.. i'm pretty new to php and really foreign to AJAX .. Can anyone tell me how i can change a php variable with a ajax slider without refreshing the page (meaning instantly)... i'll try give you a example if your not getting what i'm saying or need more info... ok say i have a normal php file with a ajax slider on it... and the php goes : $num1 = $_GET['number']; $num2 = 3; $num3 = 5; $total = $num1 + $num2 * $num3; echo "".$num1." + ".$num2." * ".$num3." = ".$total; now how could i set number which will be from the slider... If you still dnt understand just let me know and i'll try clear it up... Any help is appreciated.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.