For jqGrid, how to do autocomplete under several input boxes, namely A, B, C. After the input A, autocomplete values provided by B need to have a reference from input A.
For the dataInit at input B, I can only get the original content of input A, not the current input one.
Any idea or link so that I can pay attention to. Thanks
B/R Gene Leung
Here is the code:
...
{ name:'order_no',
index:'order_no',
align:"center",
width:80,
editable:true,
editoptions:
{
dataInit: function (elem) {
myAutocomplete(elem, "./autoComplete.php?id=sales_no");
},
dataEvents: [
{ type: 'change',
fn: function(e) {
savedSalesNo = $(this).val();
//console.log( savedSalesNo );
}
}
]
}
},
{ name:'item_no',
index:'item_no',
width:120,
editable:true,
editoptions:
{
dataInit: function (elem) {
myAutocomplete(elem, "./autoComplete.php?id=sales_items&vchr_no=" + savedSalesNo);
}
}
},
... php code: ... if isset($_GET["term"])) $maskTP = $_GET['term']; else $maskTP = "";
$sWhere = "WHERE 1=1";
if($maskTP!='') { switch ($_GET["id"]) { case "sales_no": $sWhere.= " AND name LIKE '%$maskTP%'"; $sSQL = "SELECT name AS order_no FROM sale_order ". $sWhere ." ORDER BY name"; break;
case "sales_items":
$sWhere.= " AND name LIKE '%$maskTP%'";
$sSQL = "SELECT name AS order_no FROM sale_order ". $sWhere ." ORDER BY name";
break;
}
}
$result = $db->Execute( $sSQL );
Can you post some code snippet it will be helpful.
But looking at your question what i understand is you need to autocomplete in B based on A and so on.
So what you can do is while making ajax request for the B autocomplete check the value A and pass it in your call and perform your business logic.