Hi I have two dropdown forms (but you need to start typing before the suggested word shows), the first dropdown called "Products" then the second one is called "Goods", I want that if the user chooses a Products Dropdown, the Goods Dropdown will be hidden and the Fieldrequire will also be false. Vice Versa If the user chooses a Goods Dropdown, the Products Dropdown wil be hidden and the Fieldrequire will be false. Please Help me to solve this problem. I have seen the same problem with mine, but none of them worked for me
here is the Product dropdown Code:
<?php if( (!isset($_POST["quickAddOnly"])) || "NO" == "NO" ){ ?>
<tr style="">
<td valign=top class="tb" scope="row"> <label for="Product">Product</label> <span class="required" style="color:red" >*</span> </td>
<td valign=top>:</td>
<td scope="row">
<?php
$keyrow = getProductsFilters(array_qval( $data, "product_id" , "" ),"name");
$forid = "";
$forid .= $keyrow["raw_name"];
?>
<input fieldError="Place a valid Product" fieldRequire="yes" type="hidden" name="product_id" id="Product" value="<?php echo trim(array_qval( $data, "product_id" , "" ));?>"/>
<input value="<?php echo $forid;?>" type="text" name="dropdown_product_id" autocomplete="off" style="width:297px; background-color: #f5f5f5" /><br /><small>start typing for suggestive dropdown menu of Products Name</small>
<script language="javascript">
$(document).ready(function(){
$("<?php echo $useform;?>input[name=dropdown_product_id]").each(function(){
$(this).dblclick( function(){
$(this).autocomplete( "search");
});
$(this).autocomplete({
source: function( request, response ) {
var lddText = "";
$.ajax({
type: "POST",
url: "products/xml/autocompleteProducts.php",
dataType: "json",
data: {
val : request.term,
field : "name|sku",
lookup : "id",
ldd : lddText
},
success: function( data ) {
response( data );
}
});
},
minLength: 0,
select: function( event, ui ) {
$(this).siblings("input[name=product_id]:first").val(ui.item.id).trigger("change");
$(this).addClass("input-ok").removeClass("input-ajax");
},
close: function(event, ui) {
if( $(this).siblings("input[name=product_id]:first").val() == "" || $(this).siblings("input[name=product_id]:first").val() == 0)
{
$(this).removeClass("input-ok");
}
$(this).removeClass("input-ajax");
},
search: function(event, ui) {
$(this).addClass("input-ajax");
$(this).siblings("input[name=product_id]:first").val("");
}
});
})
});
</script>
</td>
</tr>
<?php } ?>
and Here is the Goods Dropdown Code :
<!-- start of goods_info -->
<?php if( (!isset($_POST["quickAddOnly"])) || "NO" == "NO" ){ ?>
<tr style="">
<td valign=top class="tb" scope="row"> <label for="Goods">Goods</label> <span class="required" style="color:red" >*</span> </td>
<td valign=top>:</td>
<td scope="row">
<?php
$keyrow = getGoods_InfoFilters(array_qval( $data, "goods_id" , "" ),"name");
$forid = "";
$forid .= $keyrow["raw_goods_info_name"];
?>
<input fieldError="Place valid Goods" fieldRequire="yes" type="hidden" name="goods_id" id="Goods" value="<?php echo trim(array_qval( $data, "goods_id" , "" ));?>"/>
<input value="<?php echo $forid;?>" type="text" name="dropdown_goods_id" autocomplete="off" style="width:297px; background-color: #f5f5f5" /><br /><small>start typing for suggestive dropdown menu of Products Name</small>
<script language="javascript">
$(document).ready(function(){
$("<?php echo $useform;?>input[name=dropdown_goods_id]").each(function(){
$(this).dblclick( function(){
$(this).autocomplete( "search");
});
$(this).autocomplete({
source: function( request, response ) {
var lddText = "";
$.ajax({
type: "POST",
url: "goods_info/xml/autocompleteGoods_Info.php",
dataType: "json",
data: {
val : request.term,
field : "name|upteam_sku",
lookup : "id",
ldd : lddText
},
success: function( data ) {
response( data );
}
});
},
minLength: 0,
select: function( event, ui ) {
$(this).siblings("input[name=goods_id]:first").val(ui.item.id).trigger("change");
$(this).addClass("input-ok").removeClass("input-ajax");
},
close: function(event, ui) {
if( $(this).siblings("input[name=goods_id]:first").val() == "" || $(this).siblings("input[name=goods_id]:first").val() == 0)
{
$(this).removeClass("input-ok");
}
$(this).removeClass("input-ajax");
},
search: function(event, ui) {
$(this).addClass("input-ajax");
$(this).siblings("input[name=goods_id]:first").val("");
}
});
})
});
</script>
</td>
</tr>
<?php } ?>
<!-- end of goods info --->