按钮单击附加查询字符串

时间:2019-04-20 05:42:54

标签: javascript html5

每次单击提交按钮时,查询字符串(我希望使用正确的术语)就会附加在网址中。

我删除了引起它的form标记,但它仍然可以执行。我还删除了类型=“ Submit”和相同的结果

here is the html
<div class="row" style="padding-left: 20%; padding-right: 20%;  margin-top: 2%;">
    <div class="col" id="accordion1" style="padding-bottom: .4%;">
        <div class="card">
            <div class="card-header" id="headingOne">
                <h5 class="mb-0">
                    <button class="btn btn-accordions" data-toggle="collapse" data-target="#collapseOne" aria-expanded="true" aria-controls="collapseOne">DIRECT REFERRAL ▼</button>
                </h5>
            </div>

            <div class="collapse" id="collapseOne" aria-labelledby="headingOne" data-parent="#accordion1">
                <div class="card-body">
                    <form>
                        <div class="input-group mb-3">
                            <input type="number" step="any" id="dirInpt" class="form-control" name="dirInpt" placeholder="Input Amount" value="<?php echo $drctRfrl; ?>">

                            <div class="input-group-append">
                                <button class="comSet btn btn-success">SUBMIT</button> 
                            </div>
                        </div>
                    </form>
                </div>
            </div>

            <div class="card-header" id="headingTwo">
                <h5 class="mb-0">
                    <button class="btn btn-accordions" data-toggle="collapse" data-target="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">INDIRECT REFERRAL ▼</button>
                </h5>
            </div>

            <div class="collapse" id="collapseTwo" aria-labelledby="headingTwo" data-parent="#accordion1">
                <div class="card-body">
                    <form>
                        <div class="input-group mb-3">
                            <input type="number" step="any" class="form-control" name="indirInpt" placeholder="Input Amount" value="<?php echo $indrctRfrl; ?>">

                            <div class="input-group-append">
                                <button class="comSet btn btn-success">SUBMIT</button> 
                            </div>
                        </div>
                    </form>
                </div>
            </div>

            <div class="card-header" id="headingThree">
                <h5 class="mb-0">
                    <button class="btn btn-accordions" data-toggle="collapse" data-target="#collapseThree" aria-expanded="false" aria-controls="collapseThree">TEAM BUILDING BONUS ▼</button>
                </h5>
            </div>

            <div class="collapse" id="collapseThree" aria-labelledby="headingThree" data-parent="#accordion1">
                <div class="card-body">
                    <form>
                        <div class="input-group mb-3">
                            <input type="number" step="any" id="tbbInpt" class="form-control" name="tbbInpt" placeholder="Input Amount" value="<?php echo $tbb; ?>">

                            <div class="input-group-append">
                                <button class="comSet btn btn-success">SUBMIT</button> 
                            </div>
                        </div>
                    </form>
                </div>
            </div>

            <div class="card-header" id="headingFour">
                <h5 class="mb-0">
                    <button class="btn btn-accordions" data-toggle="collapse" data-target="#collapseFour" aria-expanded="false" aria-controls="collapseFour">COMPANY SUPPORT ▼</button>
                </h5>
            </div>

            <div class="collapse" id="collapseFour" aria-labelledby="headingFour" data-parent="#accordion1">
                <div class="card-body">
                    <form>
                        <div class="input-group mb-3">
                            <input type="number" step="any" id="tlsInpt" class="form-control" name="tlsInpt" placeholder="Input Amount" value="<?php echo $tls; ?>">

                            <div class="input-group-append">
                                <button class="comSet btn btn-success">SUBMIT</button> 
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
my js code
    $('.ComSet').click(function()
    {

        var dirInpt = $('#dirInpt').val();
        var indirInpt = $('#indirInpt').val();
        var tbbInpt = $('#tbbInpt').val();
        var tlsInpt = $('#tlsInpt').val();

        var direct = <?php echo $drctRfrl; ?>;
        var indir = <?php echo $indrctRfrl; ?>;
        var tbb = <?php echo $tbb; ?>;
        var tls = <?php echo $tls; ?>;



        if (dirInpt == '' || indirInpt == '' || tbbInpt == '' || tlsInpt == '') 
        {
            $(".adminErrMsg").attr("hidden", false);

            var timePeriodInMs = 3000;
            setTimeout(function() 
            { 
                $(".adminErrMsg").attr("hidden", true); 
            }, 
            timePeriodInMs);
        }
        else
        {

            dirInpt = checkNums(dirInpt, direct);
            indirInpt = checkNums(indirInpt, indir);
            tbbInpt = checkNums(tbbInpt, tbb);
            tlsInpt = checkNums(tlsInpt, tls);

            alert(dirInpt+"<br/>"+indirInpt+"<br/>"+tbbInpt+"<br/>"+tlsInpt);

        }
    });

我打算提醒数据以检查我的脚本和函数是否均正常工作。我希望它不要将文本框值附加到url中并得到警报

0 个答案:

没有答案