sakthi sakthi - 1 month ago 8
CSS Question

Uncaught SyntaxError: missing ) after argument list JS

I am applying my array results to view but i am not sure how to pass multiple array values in var. I am getting SyntaxError.

var html = '<div class="cr-content"><div class="bank-rates"><ul><li><div class="innr-spl" style="padding: 5px 0;"><span style="display:block;"><img src="+ imageUrl.join"></span><span class="hide">'+ bankName.join("</span></div></li><li><div class=\"innr-spl2\">")+ interestRateMin.join("</div></li><li><div class=\"innr-spl2\">")+ financing.join("</div></li><li class=\"hide\"><div class=\"innr-spl3 kmore\" id=""><i class=\"fa fa-chevron-circle-down\" aria-hidden="true"></i>View Datails</div></li><li><div class="apply-now innr-spl"><a href="http://www.yuho.com/gold-loan/" type="button" role="button" target="_blank" class=\"btn-apply\">Apply Now</a></div></li></ul><div style="clear:both"></div><ul class=\"details\" id="ban_" style = "display:none;"><li><i class=\"fa fa-thumbs-o-up\" aria-hidden="true"></i> Maximum Loan Amount : +maxLoanAmt.join")+'</li><li><i class=\"fa fa-thumbs-o-up\" aria-hidden="true"></i> Max Tenure (In Years) :+repaymentTenureInYears.join'+("</li><li><i class=\"fa fa-thumbs-o-up\" aria-hidden="true"></i> Interest Rate Type : +rateType.join")+'</ul></div></div>' ;


This is my html and css tags in this i want to apply my array result.

<div class="cr-content">
<div class="bank-rates">
<ul>
<li>
<div class="innr-spl" style="padding: 5px 0;">
<span style="display:block;"><img src="'.$json["resultList"][$key]["imageUrl"].'"></span>
<span class="hide">'.$json["resultList"][$key]["bankName"].'</span>
</div>
</li>

<li><div class="innr-spl2">' . $interest . '%' . '</div></li>
<li><div class="innr-spl2">' . $financing . '</div></li>
<li class="hide"><div class="innr-spl3 kmore" id="'.$key.'"><i class="fa fa-chevron-circle-down" aria-hidden="true"></i>View Datails</div> </li>
<li>
<div class="apply-now innr-spl"><a href="http://www.yuho.com/gold-loan/" type="button" role="button" target="_blank" class="btn-apply">Apply Now</a></div>
</li>
</ul>
<div style="clear:both"></div>

<ul class="details" id="ban_'.$key.'" style = "display:none;">
<li><i class="fa fa-thumbs-o-up" aria-hidden="true"></i> Maximum Loan Amount : '.$json["resultList"][$key]["maxLoanAmt"].'</li>
<li><i class="fa fa-thumbs-o-up" aria-hidden="true"></i> Max Tenure (In Years) : '.$json["resultList"][$key]["repaymentTenureInYears"].'</li>
<li><i class="fa fa-thumbs-o-up" aria-hidden="true"></i> Interest Rate Type : '.$json["resultList"][$key]["rateType"].'</li>
</ul>

</div>
</div>


My array

var rateType = [];
data.forEach(function(element){
this.push(element.rateType);
}, rateType );

var interestRateMin = [];
data.forEach(function(element){
this.push(element.interestRateMin);
}, interestRateMin );

var financingPercentageMax = [];
data.forEach(function(element){
this.push(element.financingPercentageMax);
}, financingPercentageMax );

var interestRateMax = [];
data.forEach(function(element){
this.push(element.interestRateMax);
}, interestRateMax );

var financingPercentageMin = [];
data.forEach(function(element){
this.push(element.financingPercentageMin);
}, financingPercentageMin );

var repaymentTenureInYears = [];
data.forEach(function(element){
this.push(element.repaymentTenureInYears);
}, repaymentTenureInYears );

var maxLoanAmt = [];
data.forEach(function(element){
this.push(element.maxLoanAmt);
}, maxLoanAmt );

Answer

The problem is you are not escaping the ":

var html = '<div class="cr-content"><div class="bank-rates"><ul><li><div class="innr-spl" style="padding: 5px 0;"><span style="display:block;"><img src="+ imageUrl.join"></span><span class="hide">'+ bankName.join("</span></div></li><li><div class=\"innr-spl2\">")+ interestRateMin.join("</div></li></ul></div></div>");   
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------^----------^

Fixed Code

var html = '<div class="cr-content"><div class="bank-rates"><ul><li><div class="innr-spl" style="padding: 5px 0;"><span style="display:block;"><img src="' + imageUrl.join() + '"></span><span class="hide">' + bankName.join("</span></div></li><li><div class=\"innr-spl2\">") + interestRateMin.join("</div></li><li><div class=\"innr-spl2\">") + financing.join("</div></li><li class=\"hide\"><div class=\"innr-spl3 kmore\" id=\"\"><i class=\"fa fa-chevron-circle-down\" aria-hidden=\"true\"></i>View Datails</div></li><li><div class=\"apply-now innr-spl\"><a href=\"http://www.apnapaisa.com/gold-loan/\" type=\"button\" role=\"button\" target=\"_blank\" class=\"btn-apply\">Apply Now</a></div></li></ul><div style=\"clear:both\"></div><ul class=\"details\" id=\"ban_\" style = \"display:none;\"><li><i class=\"fa fa-thumbs-o-up\" aria-hidden=\"true\"></i> Maximum Loan Amount : " + maxLoanAmt.join("") + '</li><li><i class=\"fa fa-thumbs-o-up\" aria-hidden="true"></i> Max Tenure (In Years) :+repaymentTenureInYears.join' + ("</li><li><i class=\"fa fa-thumbs-o-up\" aria-hidden=\"true\"></i> Interest Rate Type : " + rateType.join("") + '</ul></div></div>';