lional Posted June 9, 2013 Share Posted June 9, 2013 Hi I have this script <script type="text/javascript"> $(document).ready(function(){ $("select#type").attr("disabled","disabled"); $("select#category").change(function(){ $("select#type").attr("disabled","disabled"); $("select#type").html("<option>wait...</option>"); var id = $("select#category option:selected").attr('value'); $.post("select_type.php", {id:id}, function(data){ $("select#type").removeAttr("disabled"); $("select#type").html(data); }); }); $("form#select_form").submit(function(){ var cat = $("select#category option:selected").attr('value'); var type = $("select#type option:selected").attr('value'); if(cat>0 && type>0) { var result = $("select#type option:selected").html(); $("#result").html('your choice: '+result); } else { $("#result").html("you must choose two options!"); } return false; }); }); </script> What I would like to do is instead of displaying output var result = $("select#type option:selected").html();$("#result").html('your choice: '+result); I would like ti redirect the post in the form of POST to another page. Any help would be appreciated Thanks Lional Quote Link to comment https://forums.phpfreaks.com/topic/278957-redirect-to-another-page-instead-of-print/ Share on other sites More sharing options...
requinix Posted June 9, 2013 Share Posted June 9, 2013 Then use the normal form mechanisms without trying to AJAX it. Quote Link to comment https://forums.phpfreaks.com/topic/278957-redirect-to-another-page-instead-of-print/#findComment-1434962 Share on other sites More sharing options...
lional Posted June 9, 2013 Author Share Posted June 9, 2013 Thanks Do I leave this section out then $("form#select_form").submit(function(){var cat = $("select#category option:selected").attr('value');var type = $("select#type option:selected").attr('value');if(cat>0 && type>0){var result = $("select#type option:selected").html();$("#result").html('your choice: '+result);}else{$("#result").html("you must choose two options!");}return false;}); Quote Link to comment https://forums.phpfreaks.com/topic/278957-redirect-to-another-page-instead-of-print/#findComment-1434966 Share on other sites More sharing options...
trq Posted June 9, 2013 Share Posted June 9, 2013 Do you understand what Ajax is? Do you understand what your own code does? Quote Link to comment https://forums.phpfreaks.com/topic/278957-redirect-to-another-page-instead-of-print/#findComment-1434980 Share on other sites More sharing options...
Irate Posted June 9, 2013 Share Posted June 9, 2013 Ajax is used just because you don't want to reload pages, so you dynamically load additional data via XMLHttpRequests. As trq said, try looking up the basics of Ajax. If you want to prevent the page from reloading when submitting a form, use jQuery(document.forms).submit(function(e){ e.preventDefault(); /* your code here */ }); Quote Link to comment https://forums.phpfreaks.com/topic/278957-redirect-to-another-page-instead-of-print/#findComment-1434985 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
× Pasted as rich text. Restore formatting
Only 75 emoji are allowed.
× Your link has been automatically embedded. Display as a link instead
× Your previous content has been restored. Clear editor
× You cannot paste images directly. Upload or insert images from URL.