I know 2 drop down list ajax and php without press submit button

<!-- for dropdown list example only -->
<ul>
<li id='value1'>value1</li>
<li id='value2'>value2</li>
</ul>

<!--- for your ajax script -->
<script>
$(document).ready(function(){
  var val1 = $("#value1").val();    <---- create a variable for value1
  var val2 = $("#value2").val();    <---- create a variable for value2
  <?php  if(val1 != ""){ ?>         <---- create a variable for your data
  var postData = "value1=" + val1;
  <?php }else{?>		
  var postData = "value2=" + val2;
  <?php } ?>

  $.ajax({    
     type: "POST",                 <---- your type here if POST or GET
     data: postData,               <---- your data
     url: "yourfolder/yourfilename.php",     <---- your url if its on the separate folder
     success: function(msg){               <---- yor your function after executing your ajax
         if(val1 == ""){
             alert(msg);
             val1 = val2;
             window.location = "yournextpage.php";       <---- your next location
         }else{
             alert(msg);
             window.location = "yournextpage.php";       <---- your next location
         }
     }
  });	

});
</script>

Example...First table (category table) Ands Second table (sub category table).Drop down list is 2 box.1st drop down list in choose "Fruit Category" ,and then Fruit result show.2nd drop down list in choose "Banana subcategory",and then Fruit-->Banana--> Result show.

These problem solve with ajax and php.

These problem no press submit button.

Please Help me..

well the code i gave u is just part of a simple program. if you could see there is no click function for the button coz there is no button needed to your ajax.
this part:
<?php if(val1 != ""){ ?>
var postData = "value1=" + val1;
<?php }else{?>
var postData = "value2=" + val2;
<?php } ?>

the postData variable determine if you choose what value you will use from your drop down that is why there is an if-else statement.

Hi

try the below code. it will help you to solve your issue

category.php

<script type="text/javascript">

function showcategory_table(str1)
{
if (str1=="")
  {
  document.getElementById("txtHint1").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("txtHint1").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","getcategory_table.php?q1="+str1,true);
xmlhttp.send();
}
</script>

<select name="category_table" class="dropmenu" id="category_table" onchange="showcategory_table(this.value)">
    				<option selected>Select Material Name</option><?PHP $uomq=mysql_query("select * FROM category_table order by material_master_name");
						 	while($uomr=mysql_fetch_array($uomq)) {?>
        <option value="<?PHP echo $uomr['material_master_code'];?>"<?PHP if($uomr['material_master_code']==$row['material_master_code']){?><?PHP } ?>><?PHP echo $uomr['material_master_name'];  } ?></option>
    </select>
    
   Sub category : <div id="txtHint1"></div>

getcategory_table.php

session_start();
include("config.php");
// Check, if username session is NOT set then this page will jump to login page

$q1=$_GET["q1"];

$sql="SELECT * FROM sub_category_table WHERE material_master_code = '".$q1."'";
//echo $sql;
$result = mysql_query($sql);
$row = mysql_fetch_array($result);

<select name="sub_category_table" id="sub_category_table" class="dropmenu">
        	<option selected="selected">Select sub_category_table<?PHP $uomq=mysql_query("select * FROM material_master_subcat WHERE material_master_code = '".$q1."'");
						 	while($uomr=mysql_fetch_array($uomq)) {?></option>
        <option value="<?PHP echo $uomr['sub_category_table'];?>"<?PHP if($uomr['sub_category_table']==$row['sub_category_table']){?><?PHP } ?>><?PHP echo $uomr['material_subcat_name'];  } ?></option>
          </select>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.