如果使用javascript其他条件,如何隐藏和显示按钮内部

时间:2017-01-13 14:07:48

标签: javascript jquery html zend-framework

我写了一个js函数,通过取值插入文本字段来检查条件。如果条件为真,我需要隐藏一个按钮。并且我再次更改了文本字段中的值。然后条件失败,所以我想显示相同的按钮而不刷新页面。我怎样才能做到这一点? 我尝试使用下面的代码,它的隐藏按钮,但在我更改输入值后,它没有取消隐藏相同的按钮而没有刷新。一旦我刷新它即将到来的页面。 代码在下面给出

    <script type="text/javascript">
   $(document).ready(function(){

        $('#buy_now_price').keydown(function(){

            var a2=parseInt($('#reserved_price').val());
                    var a3=parseInt($('#Purchased_price').val());
                    var a4=parseInt($('#buy_now_price').val());

                    if(a2 >= a3 && a2 >= a4)
                    {
                        alert("Ensure the minimum price should be lesser than the Purchased and Buy now price");
                        document.getElementById("save").style.display='none';
                        document.getElementById("product").addEventListener("click", function(event){
                            event.preventDefault()

                        });


                    }
                    else{}
            });
    });
         // $("#type option[value='null']").attr("disabled","disabled");

         </script>

html部分是

<form action="<?= $this->form->getAction() ?>" method="<?= $this->form->getMethod() ?>" class="stdform stdform2" id="product" enctype="multipart/form-data">
                <?= $this->form->employee_id ?>
                <p>
                    <?= $this->form->name ?>
                </p>                            
                <p>
                    <?= $this->form->type ?>
                </p>
                <p>
                    <?= $this->form->brand ?>
                </p>
                <p>
                    <?= $this->form->model ?>
                </p>
                <p>
                    <?= $this->form->condition ?>
                </p>
                <p>
                    <?= $this->form->about ?>
                </p>
                <p>
                    <?= $this->form->listedon ?>
                </p>
                <p>
                    <?php echo $this->form->reserved_price; ?>
                </p>
                <p>
                    <?php echo $this->form->Purchased_price; ?>
                </p>
                <p>
                    <?php echo $this->form->buy_now_price; ?>
                </p>
                <p>
                    <?= $this->form->sale_end_date ?>
                </p>

                <p class="stdformbutton">
                    <?= $this->form->save ?>
                    <?= $this->form->cancel ?>
                </p>    

            </form>                         

0 个答案:

没有答案
相关问题