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:
<?php
        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="" />
            </a>
        </div><!-- end masquehome -->
     
          <?php
          }
        ?>

 

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 == "")
    {
    }
else
    {
    document.write ("<img src='<%=getCurrentAttribute('item','custitembrand_logo')%>' />")
    }
</script>


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