是否可以使用发布的数据显示/隐藏div?

时间:2019-07-27 18:33:15

标签: javascript php post

我有显示/隐藏的jQuery代码,可用于新订单输入。我还希望能够显示所选内容来编辑现有订单。这可能吗?

我不确定从这儿去哪里。我想就我是否想要做的事情提供建议,而不必为该特定命令编写限制性的php代码。

这有效:

                <!-- g-service: Services -->
                <div class="g-service"><p class="subtitle">Service<span class="glyphicon-asterisk input-sm req"></span></p>
                    <div class='radio radiogap'><label><input type='radio' name='service' class='service' id='Embroidery' value=='1' checked required /><b>Embroidery</b></label></div>
                    <div class='radio radiogap'><label><input type='radio' name='service' class='service' id='Screen Printing' value=='2' required /><b>Screen Printing</b></label></div>
                        <label>
                            <input type="radio" name="service" class="service" id="Other" value="Other" required />
                            <input type="text" name="serviceOther" class="serviceOther" id="serviceOther" placeholder="Other Service" size="15" />
                        </label>
                    </div>
                    <br />
                </div>

                <!-- g-provider: provider -->
                <div class="g-provider">
                    <div id="divEmbroidery" class="serviceDiv" style="display:none;">
                        <p class="subtitle">Embroidery</p>
                        <div class="radio radiogap">
                            <div class='radio radiogap'><label><input type='radio' name='provider' value='1' checked required /><b>DBE</b></label></div>
                            <div class='radio radiogap'><label><input type='radio' name='provider' value='2' required /><b>YNI</b></label></div>
                            <div class='radio radiogap'><label><input type='radio' name='provider' value='3' required /><b>HGP</b></label></div>
                            <div class='radio radiogap col-sm-14'>
                                <label>
                                    <input type='radio' name='provider' class='provider' value='Other' required />
                                    <input type='text' name='otherProvider' id='op' placeholder='Other Provider' size='20' value=''  />
                                </label>
                                <br />
                            </div>
                        </div>
                    </div>
                    <div id="divScreen" class="serviceDiv" style="display:none;">
                        <p class="subtitle">Screen Printing</p>
                        <div class="radio radiogap">
                            <div class='radio radiogap'><label><input type='radio' name='provider' value='2' required /><b>YNI</b></label></div>
                            <div class='radio radiogap'><label><input type='radio' name='provider' value='3' required /><b>HGP</b></label></div>
                            <div class='radio radiogap col-sm-14'>
                                <label>
                                    <input type='radio' name='provider' class='provider' value='Other' required />
                                    <input type='text' name='otherProvider' id='op' placeholder='Other Provider' size='20' value=''  />
                                </label>
                                <br />
                            </div>
                        </div>
                    </div>
<!-- ******************************************************************************************************************************************* -->
                <script type="text/javascript">
                    $(document).ready(function() {
                        $(".service").click(function(event) {
                            $(".serviceDiv").hide();
                            var id = $(event.target).attr('id');
                            $("#div"+id).show();
                        });
                    });
                </script> 

第一个div <div class="g-service">的显示与选中的Embroidery一样。但是,不显示第二个div <div class="g-provider">。对于上面的代码,我希望<div id="divEmbroidery" class="serviceDiv" style="display:none;">在DBE被选中的情况下显示。但是,不会显示该div的网格位置。

这是PHP代码

if ($_POST['wko'] < 1) {
    echo "<p>New Workorder </p>";
} else {
    echo "<p> Existing Workorder </p>";
    $sql = "SELECT * FROM tbl_workorder WHERE woID = ".$workordernumber;
    $row = row($sql);
    $serviceCK = $row['serviceID'];
    $providerCK = $row['providerID'];
}
...

$serviceSEL = "";
$sql = "SELECT * FROM `service` ORDER by serviceID";
$result = structure($sql);
foreach ($result as $row) {
    $CK = "";
    if ($row['serviceID'] == $serviceCK) { $CK = " checked";}
    $serviceSEL .= "                    <div class='radio radiogap'><label><input type='radio' name='service' class='service' id='".$row['service']."' value=='".$row['serviceID']."'".$CK." required /><b>".$row['service']."</b></label></div>\n";
$e_provider = "";
$sql = "SELECT * FROM `providers` WHERE Embroidery = 'Y'";
$result = structure($sql);
foreach($result as $row)  {
    $CK = "";
    if ($row['providerID'] == $providerCK) { $CK = " checked"; } 
    $e_provider .= "                            <div class='radio radiogap'><label><input type='radio' name='provider' value='".$row['providerID']."'".$CK." required /><b>".$row['provider']."</b></label></div>\n";
}
$e_provider .= $providr;
}
$s_provider = "";
$sql = "SELECT * FROM `providers` WHERE screenprinting = 'Y'";
$result = structure($sql);
foreach($result as $row)  {
    $CK = "";
    if ($row['providerID'] == $providerCK) { $CK = " checked"; }
    $s_provider .= "                            <div class='radio radiogap'><label><input type='radio' name='provider' value='".$row['providerID']."'".$CK." required /><b>".$row['provider']."</b></label></div>\n";
}
$s_provider .= $providr;

我可以编写代码来绕过此操作,但这可能会限制用户更改提供程序的能力。

0 个答案:

没有答案