Support the ongoing development of Laravel.io →
Input Blade Forms

Hi I am trying to include a {{ Form::text }} inside an inline javascript is this possible or I just got it wrong? thank you.

    var html_ship = "<tr><td><div class='col-sku'> {{ Form::text('sku[]', '', array('class'=>'col-sku')) }}</div></td></tr>";
    
    //add item
    $("#add-item").on('click', function() {
       $("#table-shipping tr:last").after(html_ship);
    });

Thank you in advance for your response.

James

Last updated 2 years ago.
0

If the javascript is generated in a blade file this should be fine - what errors are you getting?

Last updated 2 years ago.
0

Try using ' instead of ". Form::text will wrap the attributes with quotes which is probably breaking your javascript.

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

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.

© 2025 Laravel.io - All rights reserved.