自动填写表单取决于下拉列表

时间:2017-08-24 13:13:44

标签: php mysql

我有一个网络应用程序,我用PHP,HTML和MySQL构建,允许用户管理产品编号和索取新的产品编号。我希望在下面的“创建产品”表单中添加的是让下一个产品编号自动填充零件编号(id),具体取决于所选的产品系列。现在,我就像在产品系列选择器的前3个字符中显示的零件编号字段中填充的前3个字符一样。最后,我希望选择下一个可用的部件号(例如CEG005,如果最后一个是CEG004),但显然我需要使用数据库。我知道我可以用PHP if语句执行此操作,但我不希望页面重新加载。

<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method="post">

<table class='table table-hover table-responsive table-bordered'>

    <tr>
        <td>Product Name</td>
        <td><input type='text' name='name' class='form-control' /></td>
    </tr>

    <tr>
        <td>Product Family</td>
        <td><select class="selectpicker" name='family'>
            <option selected="selected" disabled="true">--Please Select--</option>
            <option value="Express">CEG - Express</option>
            <option value="Carrier">CRG - Carrier</option>
            <option value="Adapter">ADG - Adapter</option>
            <option value="Smart">SMG - Smart</option>
            <option value="Mini">MIG - Mini</option>
            </select>
        </td>

   <tr>
        <td>Part Number (ID)</td>
        <td><input type='text' name='id' class='form-control' /></td>
    </tr>

    <tr>
        <td>External Description</td>
        <td><textarea name='ext_description' class='form-control'></textarea></td>
    </tr>

    <tr>
        <td>Internal Description</td>
        <td><textarea name='description' class='form-control'></textarea></td>
    </tr>

    <tr>
        <td>PRF #</td>
        <td><input type='text' name='PRF' class='form-control' /></td>
    </tr>

    <tr>
        <td>Publish</td>
        <td><input type="checkbox" name="publish"  value="1" id="checkbox" <?php if(isset($_POST['publish'])) echo "checked='checked'";?>/></td>
    </tr>


        <input type='hidden' name='creator' class='form-control' value="<?php echo $userRow['user_name']; ?>"/></td>

    <tr>
        <td></td>
        <td>
            <button type="submit" class="btn btn-primary">Create Product</button>
        </td>
    </tr>

</table>

基本上,如果有人选择&#34; CEG - Express&#34;在产品系列中,我希望下一个字段(产品编号)自动填充&#34; CCG&#34;

0 个答案:

没有答案
相关问题