Jump to content

redirect to another page instead of print


lional

Recommended Posts

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

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;
});

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 */ });

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.