One of which is by reading MySQL data by PHP and store it to javascript variables. In this way, we could use the capability of javscript to instantly manipulate HTML forms, such as 'auto-complete' functions.
Code: Select all
echo "
<SCRIPT language='javascript'>
var AllItems = new Array();";
$query = "SELECT ItemCode,ItemName,CatergoryID,SellingPrice FROM tblItem";
$result = mysql_query($query);
while($data = mysql_fetch_array($result)){
echo "
var Item = new Array();
Item['item'] = $data[ItemName];
Item['price'] = $data[SellingPrice];
Item['catid'] = $data[CategoryID];
AllItems[$data[ItemCode]] = Item;
";
}
echo "
function AutoComplete(){
// will use AllItems array
}
function RecordNotExists(){
// will use AllItems array
}
function CalculatePrice(){
// will use AllItems array
}
</SCRIPT>
";Is it advisable to use? What is you views about this technique?
Any answer is acceptable.