The right way formatimg the JS code

Posted 1 month ago by johnef_sh

Hi guys good day for you all, I'd like o understand how to format this code

<script>
        let counter = 1;
        let limit = 10;

        function addInput(divName) {
            if (counter === limit) {
                alert("You have reached the limit of adding " + counter + " inputs");
            } else {
                let newdiv = document.createElement('div');
                newdiv.innerHTML = '<div class="col-md-12 col-md-pull-1"><div class="col-md-6">{!! Form::text("measurements[' + (counter + 1) + '][width]", null, ["class"=>"form-control", "placeholder" => trans("interface.width")]) !!}</div>';
                document.getElementById(divName).appendChild(newdiv);
                counter++;
            }
        }
    </script>

Here in Form::text("measurements[' + (counter + 1) + '][width]" I try to put this ' + (counter + 1) + ' in the array index but seems it's not reading the code right.

so what should be the right format here.

thanks

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.