0

我是 jquery 的新手,在下面的代码中,当我单击添加新部件时,链接使用 jquery 展开,其中包含使用 Json 的文件中的内容。单击提交按钮后,所有值都应存储在 mysql 中。

Html 代码将是....

<form name="zone_form" method="post" action="product_code.php" onsubmit="">
    <input type="hidden"  name="frmtype" value="new_product" />
    <table width="100%" border="0" cellpadding="2" cellspacing="0">
        <tr>
            <td valign="top">Product Name:</td>
            <td><input type="text" name="txt_pro" /></td>
            <td valign="top">Product Quantity:</td>
            <td><input type="text" name="txt_pquan" id="txt_pquan" onblur="tamount(this.value)" /></td>
            <td valign="top">Total Amount</td>
            <td><input type="text" name="txt_pamount" id="txt_pamount" /></td>
        </tr>
        <tr>
        </tr>
        <tr>
            <td colspan="6">&nbsp;</td>
        </tr>
        <tr>
            <td colspan="6"><strong>Parts Library</strong></td>
        </tr>
        <tr>
            <td valign="top">Description/Identifier:</td>
            <td valign="top"><select name="txt_desc" onchange="part_details(this.value)">
            <option value="" selected="selected">&nbsp;</option>
            <?php
            $susql= mysql_query("select * from tbl_protype");
            while ($supsql = mysql_fetch_object($susql))
            {?>
            <option value="<?php echo $supsql->part_id;?>"><?php echo $supsql->part_description;?>-<?php echo $supsql->part_identifier;?></option>
            <?php 
            } ?>
            </select>      
            </td>
            <td>Company P/N</td>
            <td><input type="text" name="txt_part" id="txt_part" /> </td>
            <td>Footprint</td>
            <td><input type="text" name="txt_foot" id="txt_foot"/></td>
            </td>
        </tr>
        <tr>
            <td valign="top">Designator</td>
            <td><input type="text" name="txt_desig" onblur="designator(this.value)"/></td>
            <td valign="top">Price</td>
            <td><input type="text" name="txt_price" id="txt_price" /></td>                  
            <td valign="top">Total Cost</td>
            <td><input type="text" name="txt_tcost" id="txt_tcost" /></td>            
       </tr>
        <tr>
            <td colspan="6"><div id="nrows"></div></td>
        </tr>
        <tr>
            <td colspan="6"><a href="" name="npart" id="npart" class="npart">Add New Part</a></td>
        </tr>           
        <tr>
            <td colspan="6" align="left"><input type="submit" id="submit" value="submit"></td>
        </tr>
    </table>
</form>

Jquery 代码将是...

$(document).ready(function(){


    var i=1;
    $('#npart').click(function(event){
    i++;

    $.get("exp.php",{frmnm: i },function(datas){

    $('div#nrows').html(datas);
    });
    event.preventDefault();
    });
});

EXP.php 文件将是....

<?php @$i = $_REQUEST['frmnm'];
echo $i;
?>
    <form name="parts_exp<?php echo $i;?>">
    <table cellpadding="1" cellspacing="">            
       <tr>
            <td valign="top">Description/Identifier:</td>
            <td valign="top"><select name="txt_desc" onchange="part_details(this.value)">
            <option value="" selected="selected">&nbsp;</option>
            <?php
            $susql= mysql_query("select * from tbl_protype");
            while ($supsql = mysql_fetch_object($susql))
            {
            ?>
            <option value="<?php echo $supsql->part_id;?>"><?php echo $supsql->part_description;?>-<?php echo $supsql->part_identifier;?></option>
            <?php 
            } ?>
            </select>      
            </td>
            <td>Company P/N <?php // echo $frmnm;?></td>
            <td><input type="text" name="txt_part" id="txt_part" /> </td>
            <td>Footprint</td>
            <td><input type="text" name="txt_foot" id="txt_foot"/></td>
            </td>
        </tr>
        <tr>
            <td valign="top">Designator</td>
            <td><input type="text" name="txt_desig" onblur="designator(this.value)"/></td>
            <td valign="top">Price</td>
            <td><input type="text" name="txt_price" id="txt_price" /></td>                  
            <td valign="top">Total Cost</td>
            <td><input type="text" name="txt_tcost" id="txt_tcost" /></td>            
       </tr>
    </table></form>

另一个问题是如何将数据存储在mysql中。

任何人请帮助我...

4

0 回答 0