sending jquery generated form to php -
i below script not work. trying pass values generated using jquery function php. when run code it. form slides right, no values encoded. thinking doing simple wrong.
<!doctype html> <html> <head> <title>target example</title> <?php $x = $_post['total']; echo $x; ?> <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0b1/jquery.mobile-1.0b1.css" /> <script src="http://code.jquery.com/jquery-1.6.1.min.js"></script> <script src="http://code.jquery.com/mobile/1.0b1/jquery.mobile-1.0b1.js"></script> <script> $(document).ready(function() { function compute() { var = $('#a').val(); var b = $('#b').val(); var total = * b; $('#total').val(total); } $('#a, #b').change(compute); }); </script> </head> <body> <form action="<?php echo $php_self;?>" method="post"> <div data-role="page" id="irr"> <div data-role="header"> <h1>calculation</h1> </div> <div data-role="content"> <div data-role="fieldcontain"> <label for="a">diameter:</label> <input type="number" name="a" id="a" value="" /> <label for="b">diver:</label> <input type="number" name="b" id="b" value="" /> <label for="total">result:</label> <input type="text" name="total" id="total" value="" /> <input type="submit"> </div> did here? </div> </div> </form> </body> </html>
your form action not set correctly. use $_server['script_name'] instead. also, used short hand echo feature in case wondering. fixes :)
<!doctype html> <html> <head> <title>target example</title> <?php $x = $_post['total']; echo $x; ?> <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0b1/jquery.mobile-1.0b1.css" /> <script src="http://code.jquery.com/jquery-1.6.1.min.js"></script> <script src="http://code.jquery.com/mobile/1.0b1/jquery.mobile-1.0b1.js"></script> <script> $(document).ready(function() { function compute() { var = $('#a').val(); var b = $('#b').val(); var total = * b; $('#total').val(total); } $('#a, #b').change(compute); }); </script> </head> <body> <form action="<?=($_server['script_name'])?>" method="post"> <div data-role="page" id="irr"> <div data-role="header"> <h1>calculation</h1> </div> <div data-role="content"> <div data-role="fieldcontain"> <label for="a">diameter:</label> <input type="number" name="a" id="a" value="" /> <label for="b">diver:</label> <input type="number" name="b" id="b" value="" /> <label for="total">result:</label> <input type="text" name="total" id="total" value="" /> <input type="submit"> </div> did here? </div> </div> </form> </body> </html>
Comments
Post a Comment