@codefishMay 15.2012 — #use the onchange event of the main category and either refresh the page or use ajax to get the html only of the subcatecory select
@mekhaauthorMay 16.2012 — #i used the ajax: [code=php] <?php require_once("base2.php"); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title> New Document </title> <meta name="Generator" content="EditPlus"> <meta name="Author" content=""> <meta name="Keywords" content=""> <meta name="Description" content=""> <script src="jquery-1.7.2.min.js" type="text/javascript" charset="utf-8"></script> <script type="text/javascript"> $(document).ready(function(){
$('#maincategory').change(function() { var id= $(this).val(); $.ajax({
type: "POST", url:'subcat.php', data: "aid="+id+,
success: function(data) { if(data){
jQuery("#childcategory").html(data) ; } } });
}) </script> </head>
<body>
<form action="" method="post"> <select id="maincategory"> <?php mysql_query("SET NAMES 'utf8'"); $result2 = mysql_query("SELECT Id as value,category_name as title FROM categories"); while($row = mysql_fetch_assoc($result2)){ extract($row);
and this is the: subcat.php [code=php] <?php include 'base2.php'; $cat =mysql_real_escape_string($_POST['aid']); mysql_query("SET NAMES 'utf8'"); $result22 = mysql_query("SELECT sub_id as value2,sub_name as title2 FROM sub_categories WHERE category_full=".$cat); while($row2 = mysql_fetch_assoc($result22)){ extract($row2);