javascript - Check checkbox and set value on load content/page -
i have shop. in cart (when user not logged) checkbox set invoice. if not checked - user bill.
on next step, user has login, , goes procced page. when user goes ahead (after login page), can't change checkbox without cart.
i need check (after login, on procced page) customer company or normal user (private) , if user company, set invoice default.
i have code: (i know not pure php - kind of framework)
<!-- cart page checkbox --> <div id="additionalrealizationinfo"> ?{foreach system.cart.optionsdata option} <label> <input class="additionalrealizationinfocheckbox" type="checkbox" ?{if true == option.option.enabled} checked="checked" ?{endif} name="additional?{=system.randomnumber}" value="${system.controllerurl}toggleoption/?{=option.name}" /> ?{=option.title} </label> ?{endforeach} // value of checkbox is: toggleoption/facture <!-- procced page without checkbox - on page, after login, user see own choice cart before login --> <div id="additionalrealizationinfo"> <h2>infos</h2> <div> ?{foreach system.cart.optionsdata option} <div> ?{if true == option.option.enabled} invoice ?{else} recive ?{endif} </div> ?{endforeach} </div> </div> <script type="text/javascript"> var iscompany = "?{=system.userlogged.invoicedata.company}"; <!-- company name --> var enableinvoice = "?{=system.cart.invoiceenabled}"; if (iscompany.lenght > 0) { $.get("${system.controllerurl}setinvoiceenabled",function(resp) { $.get("${system.baseurl}view/enableinvoice",function(resp) { $("#additionalrealizationinfo").html(resp); }); }); $.get("${system.controllerurl}toggleoption/facture",function(resp) { }); }; </script> // string check choice: ?{if system.cart.invoiceenabled} // system.baseurl/view/enableinvoice code show, invoice set default (when script works)
what's wrong. doesn't work
at first glance, i'd examine line of code:
if (iscompany.lenght > 0) { you've misspelled length. try this:
if (iscompany.length > 0) { or, depending on if value of "iscompany" variable true/false, write
if (iscompany) { // check boolean value instead hope helps!
Comments
Post a Comment