javascript - Cannot show a variable value on HTML -
i'm trying build dynamic html using jquery.
i have checkbox desired language labels of form when apply parsehtml() variables not display info.
here's code.
$desiredlanguagecompany = ""; $labelcompanyuk = "company name "; $labelcompanygerman = "unternehmen "; $labelcompanyfrench = "nom de la société "; $labelcompanyitalian = "società "; $labelcompanydanish = "virksomhedsnavn "; $labelcompanyswedish = "not provided "; $labelcompanyfinish = "yritys "; $labelcompanynorwegian = "selskap "; $formgroupcompany = '<div class="form-group">' + '<label for="inputlastname" class="control-label">' + $desiredlanguagecompany + '<span class="required">*</span></label><input type="text" aria-required="true" required="" placeholder=""' + 'id="inputlastname" class="form-control input-lg" name="last_name" /></div>';
and here functions:
$("#checkuk").change(function () { $desiredlanguagecompany = $labelcompanyuk; console.log($desiredlanguagecompany); }); $("#testbutton").click(function () { $jqueryobject = $($.parsehtml($personalizedhtml)); $('#test').append($jqueryobject); $('form').append($formgroupcompany); $('#resulttextarea').val('<!doctype html>' + $('#test').html() + '</html>'); });
so when check language option variable must set , it's doing when apply parsehtml no info variable displaying.
should different? there better way it?
thanks in advance.
when $formgroupcompany
built $desiredlanguagecompany
empty.
an alternative to call function returns html:
function getgroupcompany() { return '<div class="form-group">' + '<label for="inputlastname" class="control-label">' + $desiredlanguagecompany + '<span class="required">*</span></label><input type="text" aria-required="true" required="" placeholder=""' + 'id="inputlastname" class="form-control input-lg" name="last_name" /></div>'; }
and
$('form').append(getgroupcompany());
Comments
Post a Comment