Support the ongoing development of Laravel.io →
Views Blade Forms
Last updated 6 months ago.
0
{!! Form::select('id_x', $x) !!}  //for Laravel 5
0

Thank your for your response mkblade,

However when I use the syntax:

{!! Form::select('id_x', $x) !!} 

I keep getting this JS error: "SyntaxError: missing ; before statement" in the 'id_x' of my Select.

Last updated 7 years ago.
0

Just a thought, try switch all single quotes to doubles and doubles to single?

0

Didn't work. Keep getting the same error. It is possible to use Blade syntax inside JS?

0
Solution

You can, tho I don't recommend doing it. Using Blades means you are likely doing it in PHP file instead. I think keeping .js files by itself will allow better performance since browser stores cache on client's computer to allow quicker access.

The error "SyntaxError: missing ; before statement" is too general for us to tell what has gone wrong. Please check your chrome debugger for further more information.

Just a reminder, in Javascript, you should avoid using straight newline, that sometimes might cause unexpected problems. (It seems to me you might be on that issue. ) Try use string concatenation instead.

Example:

var html = ""

html += "<table id='tablaRazas'>";
html += "<tr>";
// blah blah blah....


document.getElementById("nombreRaza").innerHTML = html
Last updated 7 years ago.
0

Sign in to participate in this thread!

LoadForge

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2022 Laravel.io - All rights reserved.