//for js
$("select.gw").live("change",function()
{
var gpid = $(this).attr("data");
var thid = $(this).attr("id");
var gwid = $("select#"+thid+" option:selected").val();
var tmpp = "select#"+thid+" option:selected";
if(gwid!='')
{
$.post("ajax/dropdown.php", { gwid: gwid },
function(data) {
$("select#"+gpid).attr("disabled",false);
$("select#"+gpid).html(data);
});
}
else
{
$("select#"+gpid).html("");
$("select#"+gpid).attr("disabled",true);
}
});
//drop down list
<select name="gw1" id="gw1" class="gw" data="gp1"><option value="">Please Select</option>
<?php $fetRefre = mysql_query("select * from table");
while($rowGate = mysql_fetch_array($fetRefre))
{?>
<option value="<?=$rowGate['id']?>"><?=$rowGate['name']?>
<?php }?>
</select>
//ajax page
if($_POST['gwid']) {
$id = $_POST['gwid'];
$sql=mysql_query("SELECT * FROM table where gw_id =$id ");
while($row = mysql_fetch_array($sql)) {
$id=$row['id'];
$data=$row['name'];
echo "<option value=$id>$data</option>";
}
}
No comments:
Post a Comment