select ajax onchange

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
newbiephp
User
Posts: 304

select ajax onchange

Post by newbiephp »

hyy..
I have a code and it runs on php,
its works

<select class="text" name="v_formulanumber" id="v_formulanumber" style="width: 300px;" multiple="multiple" onchange="CallAjax('ajax_formula_wip', this.value)">
<option value="">-</option>
<?php
foreach($arr_data["list_formula"] as $formulanumber=>$val)
{
$formulaname = $arr_data["formulaname"][$formulanumber];
?>
<option value="<?php echo $formulanumber; ?>"><?php echo $formulaname; ?></option>
<?php
}
?>
</select>
ajax:
if($ajax=="ajax_formula_wip")
{
$v_formulanumber = $GET["v_formulanumber"];
$v_warehousecode = $
GET["v_warehousecode"];


    $v_mm   = date("m");
    $v_yyyy = date("Y");
    
    
    $q = "
            SELECT
                vci.formula.inventorycode,
                vci.formula.quantity AS qty_kg_formula
            FROM
                vci.formula
            WHERE          
                1
                AND vci.formula.formulanumber = '".$v_formulanumber."'
            LIMIT
                0,1
    ";
	
	//if($ses_login=="mechael0101"){
	//	echo $q."<br>";
	//}
	
    $qry = mysql_query($q);
    $row = mysql_fetch_array($qry);
    list($inventoryprefix, $qty_kg_formula) = $row;
    
    $counter = 0;
    $q = "
            SELECT
                vci.production.warehousecode,
                vci.production.productiondate,
                vci.production.batchnumber
            FROM
                vci.production
            WHERE
                1
                AND vci.production.formulanumber = '".$v_formulanumber."'
                AND vci.production.warehousecode = '".$v_warehousecode."'
                AND vci.production.mixquantity*1 != '0'
                AND vci.production.status_batchnumber = 'Open'
            ORDER BY
                vci.production.productiondate ASC
    ";
	
	//if($ses_login=="mechael0101"){
		//echo $q."<br>";
	//}
	
    $qry = mysql_query($q);
    while($row = mysql_fetch_array($qry))
    {
        list($warehousecode, $productiondate, $batchnumber) = $row;
        
        $arr_data["list_warehousecode"][$warehousecode] = $warehousecode;
        $arr_data["list_batchnumber"][$batchnumber] = $batchnumber;
        $arr_data["productiondate"][$batchnumber] = $productiondate;
        
        $counter++;    
    }
    
    $arr_stock = bincard_wip_stock($arr_data["list_batchnumber"]);
    
    echo $inventoryprefix;
    echo "||";
    ?>
    
    <table class="in_table_data">
        <tr class="title_table" align="center">
            <td width="30">No</td>
            <td width="100">Date</td>
            <td>BatchNumber</td>
            <td width="100">Data Qty</td>
            <td width="100">Mixing Qty</td>
        </tr>
        
        <?php 
            $no = 1;
            $all_batchnumber = "";
            foreach($arr_data["list_batchnumber"] as $batchnumber=>$val)
            {
                $productiondate = $arr_data["productiondate"][$batchnumber];
                
                ?>
                <tr onmouseover="mouseover(this)" onmouseout="mouseout(this)" onclick="mouseclick1(this)" height="25">
                    <td>
                        <?php echo $no; ?>
                        <input type="hidden" name="v_no[]" value="<?php echo $no; ?>">
                        <input type="hidden" name="v_batchnumber[]" value="<?php echo $batchnumber; ?>">
                        <input type="hidden" name="v_batchnumber_no_<?php echo $no; ?>" value="<?php echo $batchnumber; ?>">
                    </td>
                    <td style="text-align: center;"><?php echo format_show_date($productiondate); ?></td>
                    <td><?php echo $batchnumber; ?></td>
                    <td style="text-align: right;">
                        <?php echo format_number($arr_stock["sum_akhir"][$batchnumber],4); ?>
                        <input type="hidden" name="v_qty_bincard_<?php echo $no; ?>" value="<?php echo $arr_stock["sum_akhir"][$batchnumber]; ?>">
                    </td>
                    <td style="text-align: right;">
                        <input type="text" class="text" size="20" style="text-align: right;" name="v_qty_mixing_<?php echo $no; ?>" id="v_qty_mixing_<?php echo $batchnumber; ?>" value="" onkeyup="calculate_wip()" onblur="toFormat4('v_qty_mixing_<?php echo $batchnumber; ?>')">
                    </td>
                </tr> 
                <?php
                $no++;
                $all_batchnumber .= $batchnumber.",";
            }         
        ?>
        
        <tr onmouseover="mouseover(this)" onmouseout="mouseout(this)" onclick="mouseclick1(this)" height="25" style="text-align: right; font-weight: bold;">
            <td colspan="4">Total Mixing</td>
            <td id="td_total_mixing" style="text-align: right;">&nbsp;</td>
        </tr>  
    </table>
    <input type="hidden" name="v_all_batchnumber" id="v_all_batchnumber" value="<?php echo $all_batchnumber; ?>">

but I want to implement this function in the php maker, can it?
and in the menu and code I write at what events?

thanks
yku


mobhar
User
Posts: 11725

Post by mobhar »

You may try "Custom Files" feature in PHPMaker. Please read "Custom Files" topic from PHPMaker Help menu for more info and example.


newbiephp
User
Posts: 304

Post by newbiephp »

I know that custom files write php code from scratch.
Can I not use server events or clientscript?
considering that the application I built uses a lot of these features.
I think php makers can be easier.
but if you have to write in custom files just write manually.
but thanks for the answer


mobhar
User
Posts: 11725

Post by mobhar »

If you want to use and optimize the usage of Server Events and/or Client Scripts, then try to create the tables or database views as possible, and then use Server Events and Client Scripts that related to those tables and database views.


Post Reply