Ad

Button Not Responding Laravel

i have this page where i have form where the action url are same. My second form work perfectly fine but mu first form doesn't responding when i hit the button or <a>. I've try to switch the <form action="{{url('purchase')}}" method="post") between form, i've try to cut the action on second form and move it to first form still no luck... any idea? here's sum of my code

    <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 target="_blank" rel="nofollow noreferrer" href="#" class="btn btn-primary">Purchase</a>
        </div>
    </form>

that's my first form, inside of id="items" purposely empty since i fill it up with 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>

this is my second form and it work perfectly....

Ad

Answer

Change

<a target="_blank" rel="nofollow noreferrer" href="#" class="btn btn-primary">Purchase</a> 

to

<button type='submit'>Purchase</button>
Ad
source: stackoverflow.com
Ad