Variable Visions

Articles E-commerce NetSuite-IF-ELSE-statements

tutorials - E-commerce and Web-Development.

NetSuite IF ELSE statements

Published Wed. Jan. 16, 2013

Since NetSuite does not allow jsp if statements I had to use javascript

In a previous article, I wrote about "PHP IF statement for hidding NULL fields from a MySQL database".

This was done using this code:
        if ($row_new['introimage'] != NULL) {        
        <div class="masquehome">
            <a href="<?php echo $row_new['introimage'];?>" class="image lightbox">
            <img class="imageviewhome" id="imageviewhome" src="<?php echo $row_new['introimage'];?>" alt="" />
        </div><!-- end masquehome -->


Since NetSuite is not on the LAMP stack, I at least expected JSP If conditions to work...NOPE! NetSuite gold support said I should not be trying to condition my tempaltes. Well, what if we set up a custom field for a logo to display. This works great but since the NetSuite tag is the src of an image, a RED X will show if you dont want (or forgot) an item logo. Well, with the below javascript I conditioned on the client side.(with no jump upon load) NOTICE they "" is replacing !=NULL :


<script type="text/javascript">
var custitembrandlogo = "<%=getCurrentAttribute('item','custitembrand_logo')%>";
if (custitembrandlogo == "")
    document.write ("<img src='<%=getCurrentAttribute('item','custitembrand_logo')%>' />")

Tag(s): Netsuite if, else, else if statement


PUBLISHED ON 06.1.23arrowBuilding a JavaScript Metronome using Open AI Chat GPT

PUBLISHED ON 05.15.23arrowHow Do I Remove Footage Gaps in Adobe Premiere