按钮没有响应 laravel

button not responding laravel

我有这个页面,其中我有表单,其中操作 url 相同。我的第二个表单工作得很好,但是当我按下按钮或 <a> 时,mu 第一个表单没有响应。我尝试在形式之间切换 <form action="{{url('purchase')}}" method="post"),我尝试在第二种形式上削减动作并将其移至第一种形式仍然没有运气......知道吗?这是我的代码总和

    <form class="px-2 py-2" action="{{ url('purchase') }}" method="post">
        {{csrf_field()}}
        <div id="items">
        </div>
        <div class="row mx-1 px-2">
            <a href="#" class="btn btn-primary">Purchase</a>
        </div>
    </form>

这是我的第一个表格,在 id="items" 里面故意填空,因为我用 javascript

填满了它
<form id="newItemForm" style="display:none;">
  <div class="form-group row"  id="item">
    <label for="invoice" class="col-sm-2 col-form-label">Supplier</label>
    <div class="col-sm-2">
      <select class="form-control" onchange="newExisting(this)">
        <option value="#" selected>Choose Supplier</option>
        <option value="existing">Existing Supplier</option>
        <option value="new">New Supplier</option>
      </select>
    </div>
    <div class="col-sm-8" id="existingCompany" style="display:none;">
      <div class="row">
        <div class="col-sm-4">
          <select class="form-control" name="fromE" onchange="localImport(this)">
            <option value="#" checked>From</option>
            <option value="f" checked>Import</option>
            <option value="l" checked>Local</option>
          </select>
        </div>
        <div class="col-sm-8">
          <select class="form-control" name="supplier" id="supplierID">
            <option value="#">Choose Company</option>
          </select>
        </div>
      </div>
    </div>
    <div class="col-sm-8" style="display:none;" id="newCompany">
      <div class="row">
        <div class="col-sm-4">
          <select class="form-control" name="fromN">
            <option value="#" checked>From</option>
            <option value="f" checked>Import</option>
            <option value="l" checked>Local</option>
          </select>
        </div>
        <div class="col-sm-4">
          <input type="text" name="kind" value="" placeholder="PT, CV, FIRMA" class="form-control">
        </div>
        <div class="col-sm-4">
          <input type="text" name="supplierName" placeholder="Company Name" class="form-control">
        </div>
      </div>
    </div>
  </div>
    <div id="newItems">
      <div class="form-group row"  id="item">
        <label for="invoice" class="col-sm-2 col-form-label">Item Name</label>
        <div class="col-sm-10">
          <input type="text" name="item0" class="form-control" placeholder="Item Name" onkeyup="getCompanyGoods(this)">
          <span class="text text-danger" style="display:none;" id="existsWarning0">*Item already exists</span>
        </div>
      </div>
      <div class="form-row">
        <div class="form-group col-md-3">
          <label for="taxInvoice">QTY<span class="text-danger">*</span></label>
          <input type="number" name="qty0" class="form-control" id="qty0" required onkeyup="calculate(this)">
        </div>
        <div class="form-group col-md-3">
          <label for="inputPassword4">Units<span class="text-danger">*</span></label>
          <input type="number" name="units0" class="form-control" id="units0" required onkeyup="calculate(this)">
        </div>
        <div class="form-group col-md-3">
          <label for="inputPassword4">Total</label>
          <div class="form-controll font-weight-bold" style="font-size:x-large;" id="total0">IDR0.00</div>
        </div>
      </div>
    </div>
    <label class="btn btn-primary" id="newRow" onclick="addRow()">+ Item</label>
    <input type="hidden" name="type" value="new">
    <input type="hidden" name="nore" value="#" id="nore">
    <input type="number" name="totalItem" value="0" id="totalItem">
    <button name="button" class="btn btn-danger float-right" >Purchase</button>
  </form>

这是我的第二种形式,它完美地工作....

改变

<a href="#" class="btn btn-primary">Purchase</a> 

<button type='submit'>Purchase</button>

因为您使用了标签而不是按钮类型"submit"

<a href="#" class="btn btn-primary">Purchase</a>

改成这样

<button class="btn btn-primary" type="submit"> Purchase </button>