Javascript jQuery函数没有';我不在拉威尔工作

Javascript jQuery函数没有';我不在拉威尔工作,javascript,php,jquery,laravel,Javascript,Php,Jquery,Laravel,我有一个jQuery函数在Laravel下不起作用,我认为它只需要重写并以不同的方式声明 这是我在浏览器中遇到的错误: 在jQuery2.2.3的正常环境下,它可以像在 这是源代码: // replace , with . and block writing letters $.fn.ForceNumericOnly = function() { return this.each(function() { if($(this).data('forceNumeric

我有一个jQuery函数在Laravel下不起作用,我认为它只需要重写并以不同的方式声明

这是我在浏览器中遇到的错误:

在jQuery2.2.3的正常环境下,它可以像在

这是源代码:

// replace , with . and block writing letters
$.fn.ForceNumericOnly = function() {
        return this.each(function() {
      if($(this).data('forceNumericOnly')){ return; }
      $(this).data('forceNumericOnly', true);
            $(this).keydown(function(e) {
                if(e.keyCode==188 || e.keyCode==110 || e.keyCode==108){
                    e.preventDefault(); 
                    $(this).val($(this).val() + '.');
                }
                    var key = e.charCode || e.keyCode || 0;
                    return (key == 8 || key == 9 || key == 46 || key == 110 || key == 188 || key == 190 || (key >= 35 && key <= 40) || (key >= 48 && key <= 57) || (key >= 96 && key <= 105));                
            });
        });
};

// execute function on element focus
$(document).on('focus', '.amount', function(){
    $(this).ForceNumericOnly();
});
//替换为。和正楷
$.fn.ForceNumericOnly=函数(){
返回此值。每个(函数(){
if($(this.data('forceNumericOnly')){return;}
$(this).data('forceNumericOnly',true);
$(此).keydown(函数(e){
如果(e.keyCode==188 | e.keyCode==110 | e.keyCode==108){
e、 预防默认值();
$(this.val($(this.val()+');
}
var key=e.charCode | | e.keyCode | | 0;
return(key==8 | | key==9 | | key==46 | | key==110 | | key==188 | | key==190 | |(key>=35&&key=48&&key=96&&key)
    isAdmin())
  • @elseif(!Auth::guest()&&Auth::user()->isAgentur())
  • @elseif(!Auth::guest()&&Auth::user()->isEndkunde())
  • @恩迪夫
    @if(Auth::guest())
  • @否则
  • @恩迪夫
@产量(‘含量’) {{-- --}}
这是angebotmachen.blade.php

@extends('layouts.app')
@section('content')
<script src="https://code.jquery.com/jquery-2.2.3.min.js"></script>
<div class="container">
    <div class="row">
        <div class="col-md-10 col-md-offset-1">
            <div class="panel panel-default">
                <div class="panel-heading">Angebot machen</div>

                <div class="panel-body">
{{ Form::open(array('url' => 'agentur/angebotmachen', 'method' => 'POST' )) }}
<table id="t1">
    <tr>
        <th><button type="button" class="addRow">Personal hinzuf&uuml;gen</button></th>
        <th>Anzahl</th>
        <th>Preis pro Stunde</th>
        <th>Stunden</th>
        <th>Total</th>
    </tr>
    <tr id="row0" class="item">
        <td>{{ Form::select('personal[]', array(
               'koeche' => 'K&ouml;che',
               'barkeeper' => 'Barkeeper',
               'garderobiere' => 'Garderobiere',
               'chauffeure' => 'Chauffeure',
               'oberkellner' => 'Oberkellner',
               'serviceleitung' => 'Serviceleitung',
               'hilfskoch' => 'Hilfskoch',
               'servicekraefte' => 'Servicekr&auml;fte',
               ), null, ['placeholder' => '--ausw&auml;hlen']) }}
       </td>
        <td><input name="anzahl[]" class="qnty amount" value="" type="number" min="0" step="1"></td>
        <td><input name="preisps[]" class="price amount" value=""></td>
        <td><input name="stunden[]" class="hours amount" value=""></td>
        <td><input name="total[]" class="total" value="" readonly="readonly" /></td>
    </tr>
</table>

<br />

<table id="t2">
  <tr>
    <th>Netto =<br></th>
    <th>{{ Form::text('netto', '', ['id' => 'netto', 'readonly' => 'readonly']) }}</th>
  </tr>
  <tr>
    <td>Steuer 19% =<br></td>
    <td>{{ Form::text('steuer', '', ['id' => 'steuer', 'readonly' => 'readonly']) }}</td>
  </tr>
  <tr>
    <td>Brutto =<br></td>
    <td>{{ Form::text('brutto', '', ['id' => 'brutto', 'readonly' => 'readonly']) }}</td>
  </tr>
</table>
    <br>
  {{ Form::submit('Submit') }}
  {{ Form::reset('Reset') }}
  {{ Form::close() }}

                </div>
            </div>
        </div>
    </div>
</div>

<script>  
// main function when page is opened
    $(document).ready(function () {
        // function for adding a new row
        var r = 0;
        $('.addRow').click(function () {
            r++;
            $('#t1').append('<tr id="row' + r + '" class="item"><td><select name="personal[]" class="select"><optgroup label="Personal"><option selected="true" disabled="true" style="display:none">--ausw&auml;hlen</option><option value="koeche">K&ouml;che</option><option value="barkeeper">Barkeeper</option><option value="garderobiere">Garderobiere</option><option value="chauffeure">Chauffeure</option><option value="oberkellner">Oberkellner</option><option value="serviceleitung">Serviceleitung</option><option value="hilfskoch">Hilfskoch</option><option value="servicekraefte">Servicekr&auml;fte</option></optgroup></select></td><td><input name="anzahl[]" class="qnty amount" value="" type="number" min="0" step="1"></td><td><input name="preisps[]" class="price amount" value=""></td><td><input name="stunden[]" class="hours amount" value=""></td><td><input name="total[]" class="total" value="" readonly="readonly"></td><td><button type="button" name="remove" id="' + r + '" class="btn_remove">X</button></td></tr>');
        });
        // remove row when X is clicked
        $(document).on("click", ".btn_remove", function () {
            var button_id = $(this).attr("id");
            $("#row" + button_id + '').remove();
        });

        // calculate everything
        $(document).on("keyup", ".amount", calcAll);

    });

    // function for calculating everything
    function calcAll(event) {
        // calculate total for one row
          $(".item").each(function () {
            var qnty = 1;
            var price = 1;
            var hours = 1;
            var total = 1;
            if (!isNaN(parseFloat($(this).find(".qnty").val()))) {
                qnty = parseFloat($(this).find(".qnty").val());
            }
            if (!isNaN(parseFloat($(this).find(".price").val()))) {
                price = parseFloat($(this).find(".price").val());
            }
            if (!isNaN(parseFloat($(this).find(".hours").val()))) {
                hours = parseFloat($(this).find(".hours").val());
            }
            total = qnty * price * hours;
            $(this).find(".total").val(total.toFixed(2));
        });


        // sum all totals
        var sum = 0;
        $(".total").each(function () {
            if (!isNaN(this.value) && this.value.length != 0) {
                sum += parseFloat(this.value);
            }
        });

        // show values in netto, steuer, brutto fields
        $("#netto").val(sum.toFixed(2));
        $("#steuer").val(parseFloat(sum * 0.19).toFixed(2));
        $("#brutto").val(parseFloat(sum + parseFloat(($("#steuer").val()))).toFixed(2));

    }

    // replace , with . and block writing letters
    $.fn.ForceNumericOnly = function() {
            return this.each(function() {
          if($(this).data('forceNumericOnly')){ return; }
          $(this).data('forceNumericOnly', true);
                $(this).keydown(function(e) {
                    if(e.keyCode==188 || e.keyCode==110 || e.keyCode==108){
                        e.preventDefault(); 
                        $(this).val($(this).val() + '.');
                    }
                        var key = e.charCode || e.keyCode || 0;
                        return (key == 8 || key == 9 || key == 46 || key == 110 || key == 188 || key == 190 || (key >= 35 && key <= 40) || (key >= 48 && key <= 57) || (key >= 96 && key <= 105));                
                });
            });
    };
    // execute function on element focus
    $(document).on('focus', '.amount', function(){
        $(this).ForceNumericOnly();
    });

</script>
@endsection
@extends('layouts.app'))
@节(“内容”)
安格博特·马钦
{{Form::open(数组('url'=>'agentur/angebotmachen','method'=>'POST'))}
个人hinzufü;gen
安扎尔
普瑞斯职业眩晕
震惊
全部的
{{Form::select('personal[]),数组(
‘koeche’=>‘Kö;che’,
“酒保”=>“酒保”,
“garderobiere”=>“garderobiere”,
“司机”=>“司机”,
“oberkellner”=>“oberkellner”,
“服务莱东”=>“服务莱东”,
“hilfskoch”=>“hilfskoch”,
'servicekraefte'=>'Servicekrä;fte',
),null,['placeholder'=>'--auswä;hlen']}

净值=
{Form::text('netto','',['id'=>'netto','readonly'=>'readonly'])} Steuer 19%=
{Form::text('steuer','',['id'=>'steuer','readonly'=>'readonly'])} 布鲁托=
{{Form::text('brutto','',['id'=>'brutto','readonly'=>'readonly'])}
{{Form::submit('submit')} {{Form::reset('reset')} {{Form::close()}} //打开页面时的主要功能 $(文档).ready(函数(){ //用于添加新行的函数 var r=0; $('.addRow')。单击(函数(){ r++; $(“#t1')。追加(“--auswä;hlinkö;chebarkeepergarderobierechauffereoberkellnerserviceleitunghilfskochserviceckrä;fteX”); }); //单击X时删除行 $(文档).on(“单击“,”.btn_删除”),函数(){ var按钮_id=$(this.attr(“id”); $(“#行”+按钮id+”).remove(); }); //计算一切 美元(文件).on(“keyup”和“.amount”,calcAll); }); //计算一切的函数 功能CalCal(事件){ //计算一行的总数 $(“.item”)。每个(函数(){ var-qnty=1; var价格=1; var小时=1; var总计=1; if(!isNaN(parseFloat($(this).find(“.qnty”).val())){ qnty=parseFloat($(this.find(“.qnty”).val()); } if(!isNaN(parseFloat($(this).find(“.price”).val())){ price=parseFloat($(this.find(“.price”).val()); } if(!isNaN(parseFloat($(this).find(“.hours”).val())){ hours=parseFloat($(this.find(“.hours”).val()); } 总计=qnty*价格*小时; $(this.find(“.total”).val(total.toFixed(2)); }); //合计所有总数 var总和=0; $(“.total”)。每个(函数(){ 如果(!isNaN(this.value)&&this.value.length!=0){ sum+=parseFloat(此.value); } }); //在netto、steuer和brutto字段中显示值 美元(净额).val(固定总额(2);; $(“#steuer”).val(parseFloat(sum*0.19).toFixed(2)); $(“#brutto”).val(parseFloat(sum+parseFloat)(($(“#steuer”).val()).toFixed(2)); } //替换为.和正楷 $.fn.ForceNumericOnly=函数(){ 返回此值。每个(函数(){ if($(this.data('forceNumericOnly')){return;} $(this).data('forceNumericOnly',true); $(此).keydown(f
@extends('layouts.app')
@section('content')
<script src="https://code.jquery.com/jquery-2.2.3.min.js"></script>
<div class="container">
    <div class="row">
        <div class="col-md-10 col-md-offset-1">
            <div class="panel panel-default">
                <div class="panel-heading">Angebot machen</div>

                <div class="panel-body">
{{ Form::open(array('url' => 'agentur/angebotmachen', 'method' => 'POST' )) }}
<table id="t1">
    <tr>
        <th><button type="button" class="addRow">Personal hinzuf&uuml;gen</button></th>
        <th>Anzahl</th>
        <th>Preis pro Stunde</th>
        <th>Stunden</th>
        <th>Total</th>
    </tr>
    <tr id="row0" class="item">
        <td>{{ Form::select('personal[]', array(
               'koeche' => 'K&ouml;che',
               'barkeeper' => 'Barkeeper',
               'garderobiere' => 'Garderobiere',
               'chauffeure' => 'Chauffeure',
               'oberkellner' => 'Oberkellner',
               'serviceleitung' => 'Serviceleitung',
               'hilfskoch' => 'Hilfskoch',
               'servicekraefte' => 'Servicekr&auml;fte',
               ), null, ['placeholder' => '--ausw&auml;hlen']) }}
       </td>
        <td><input name="anzahl[]" class="qnty amount" value="" type="number" min="0" step="1"></td>
        <td><input name="preisps[]" class="price amount" value=""></td>
        <td><input name="stunden[]" class="hours amount" value=""></td>
        <td><input name="total[]" class="total" value="" readonly="readonly" /></td>
    </tr>
</table>

<br />

<table id="t2">
  <tr>
    <th>Netto =<br></th>
    <th>{{ Form::text('netto', '', ['id' => 'netto', 'readonly' => 'readonly']) }}</th>
  </tr>
  <tr>
    <td>Steuer 19% =<br></td>
    <td>{{ Form::text('steuer', '', ['id' => 'steuer', 'readonly' => 'readonly']) }}</td>
  </tr>
  <tr>
    <td>Brutto =<br></td>
    <td>{{ Form::text('brutto', '', ['id' => 'brutto', 'readonly' => 'readonly']) }}</td>
  </tr>
</table>
    <br>
  {{ Form::submit('Submit') }}
  {{ Form::reset('Reset') }}
  {{ Form::close() }}

                </div>
            </div>
        </div>
    </div>
</div>

<script>  
// main function when page is opened
    $(document).ready(function () {
        // function for adding a new row
        var r = 0;
        $('.addRow').click(function () {
            r++;
            $('#t1').append('<tr id="row' + r + '" class="item"><td><select name="personal[]" class="select"><optgroup label="Personal"><option selected="true" disabled="true" style="display:none">--ausw&auml;hlen</option><option value="koeche">K&ouml;che</option><option value="barkeeper">Barkeeper</option><option value="garderobiere">Garderobiere</option><option value="chauffeure">Chauffeure</option><option value="oberkellner">Oberkellner</option><option value="serviceleitung">Serviceleitung</option><option value="hilfskoch">Hilfskoch</option><option value="servicekraefte">Servicekr&auml;fte</option></optgroup></select></td><td><input name="anzahl[]" class="qnty amount" value="" type="number" min="0" step="1"></td><td><input name="preisps[]" class="price amount" value=""></td><td><input name="stunden[]" class="hours amount" value=""></td><td><input name="total[]" class="total" value="" readonly="readonly"></td><td><button type="button" name="remove" id="' + r + '" class="btn_remove">X</button></td></tr>');
        });
        // remove row when X is clicked
        $(document).on("click", ".btn_remove", function () {
            var button_id = $(this).attr("id");
            $("#row" + button_id + '').remove();
        });

        // calculate everything
        $(document).on("keyup", ".amount", calcAll);

    });

    // function for calculating everything
    function calcAll(event) {
        // calculate total for one row
          $(".item").each(function () {
            var qnty = 1;
            var price = 1;
            var hours = 1;
            var total = 1;
            if (!isNaN(parseFloat($(this).find(".qnty").val()))) {
                qnty = parseFloat($(this).find(".qnty").val());
            }
            if (!isNaN(parseFloat($(this).find(".price").val()))) {
                price = parseFloat($(this).find(".price").val());
            }
            if (!isNaN(parseFloat($(this).find(".hours").val()))) {
                hours = parseFloat($(this).find(".hours").val());
            }
            total = qnty * price * hours;
            $(this).find(".total").val(total.toFixed(2));
        });


        // sum all totals
        var sum = 0;
        $(".total").each(function () {
            if (!isNaN(this.value) && this.value.length != 0) {
                sum += parseFloat(this.value);
            }
        });

        // show values in netto, steuer, brutto fields
        $("#netto").val(sum.toFixed(2));
        $("#steuer").val(parseFloat(sum * 0.19).toFixed(2));
        $("#brutto").val(parseFloat(sum + parseFloat(($("#steuer").val()))).toFixed(2));

    }

    // replace , with . and block writing letters
    $.fn.ForceNumericOnly = function() {
            return this.each(function() {
          if($(this).data('forceNumericOnly')){ return; }
          $(this).data('forceNumericOnly', true);
                $(this).keydown(function(e) {
                    if(e.keyCode==188 || e.keyCode==110 || e.keyCode==108){
                        e.preventDefault(); 
                        $(this).val($(this).val() + '.');
                    }
                        var key = e.charCode || e.keyCode || 0;
                        return (key == 8 || key == 9 || key == 46 || key == 110 || key == 188 || key == 190 || (key >= 35 && key <= 40) || (key >= 48 && key <= 57) || (key >= 96 && key <= 105));                
                });
            });
    };
    // execute function on element focus
    $(document).on('focus', '.amount', function(){
        $(this).ForceNumericOnly();
    });

</script>
@endsection
$(document).ready(function () { 
    // etc
});