I want to print variable value inside string quote
this is my variable
var id = $(this).val();
how can i print this variable to this string
$('#button_cetak').html('<a href="{{route('report.pdf',[$user->nip,'//this is place i wanna print'])}}" ><i ></i> Cetak</a>');
thanks
CodePudding user response:
You can do it in two ways.
- 1. Make use of JavaScript String Literals
var id = $(this).val();
$('#button_cetak').html(`<a href="{{ route('report.pdf',[$user->nip,'${id}'])}}" ><i ></i> Cetak</a>`);
- 2. JavaScript dummy replace
var id = $(this).val();
var url = `<a href="{{ route('report.pdf',[$user->nip,':id'])}}" ><i ></i> Cetak</a>`;
url = url.replace(':id', id);
$('#button_cetak').html(url);
CodePudding user response:
$('#button_cetak').html('<a href="{{routr(' report.pdf ',[$user->nip,' id '])}}" ><i ></i> Cetak</a>');
This would be the correct way to concatenate.