I have written some JavaScript below. It's very simple and adds an event to a button found by it's class. When I click the button, however, nothing happens.
Please can anyone help as I have been trouble shooting this for a while and I just cannot get it.
@extends('layouts.app')
@section('content')
<h1>Create new</h1>
{{-- Purchase order --}}
{{ Form::open(['route' => 'po.store']) }}
{{ Form::label('supplier', 'Supplier') }}
{{ Form::select('supplier', [$suppliers], null, ['placeholder' => 'Select a supplier...']) }}
{{ Form::label('staff', 'Staff') }}
{{ Form::select('staff', [$staff], null, ['placeholder' => 'Select a staff member']) }}
{{ Form::label('status', 'Status' ) }}
{{ Form::select('status', [$statuses]) }}
<br>
{{ Form::label('deliverto', 'Deliver To:') }}
{{ Form::text('deliverto', '') }}
<br>
{{ Form::label('priceex', 'Price (ex VAT)') }}
{{ Form::text('priceex') }}
{{ Form::label('priceinc', 'Price (inc VAT)') }}
{{ Form::text('priceinc') }}
{{ Form::submit('Submit') }}
<hr>
{{-- Lines section--}}
<table id="linesTable">
<tr> {{--headings--}}
<th>Code</th>
<th>Quantity</th>
<th>Description</th>
<th>Price (ex VAT)</th>
<th>Price (inc VAT)</th>
<th>notes</th>
<th></th>
</tr>
<tr>
<td>{{Form::text("lines[0][code]")}}</td>
<td>{{Form::text("lines[0][quantity]")}}</td>
<td>{{Form::text("lines[0][description]")}}</td>
<td>{{Form::text("lines[0][price_ex_vat]", null, ["class" => "textbox_prices"])}}</td>
<td>{{Form::text("lines[0][price_inc_vat]", null, ["class" => "textbox_prices"])}}</td>
<td>{{Form::text("lines[0][notes]")}}</td>
<td><button type="button">Remove</button></td>
</table>
<button type="Button" id="addNew">Add New Line</button>
{{ Form::close()}}
<script type="text/javascript">
document.getElementById("addNew").addEventListener("click", insertRow);
function insertRow() {
alert('hi');
}
</script>
@endsection