1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Rep Power

    Need Help Formating If/Or Statement

    I am in desperate need of help. I have never done Javascript until about 2 weeks ago. I was able to fix a code to get the top bar of my page to open some links in a new window but I need for multiple to stay in the browser but so far this code only allows for one to do that. I am perplexed as to how I should write the If/Or code for this:

    <ul id="toptoolbarlinklist"><{foreach key=key item=_item from=$_widgetContainer}><{if $_item[displayinnavbar] == '1'}><li<{if $_item[isactive] == true}> class="current"<{/if}>>
    <{if $_item[defaulttitle] != 'Knowledgebase'}>
    <{else if $_item[defaulttitle] == 'Learning Portal Login'}>
    <{else if $_item[defaulttitle] == 'Update Contact Information'}>
    <{else if $_item[defaulttitle] == 'Contact Us'}>
    <a class="toptoolbarlink" style="<{if $_item[defaultsmallicon] != ''}>background-image: url(<{$_item[defaultsmallicon]}>);<{/if}>" href="<{$_item[widgetlink]}>"><{$_item[defaulttitle]}></a>
    <{if $_item[defaulttitle] != 'Knowledgebase'}>
    <a class="toptoolbarlink" style="<{if $_item[defaultsmallicon] != ''}>background-image: url(<{$_item[defaultsmallicon]}>);<{/if}>" href="<{$_item[widgetlink]}>" target="_blank" ><{$_item[defaulttitle]}></a>
    <{if $_item[defaulttitle] != 'Knowledgebase'}>
    I need for two links to not open in a new window. So in addition to "Knowledgebase" I also need "Home" to stay within the browser.

    I have tried to change 2 the lines to:
    <{if $_item[defaulttitle] != 'Knowledgebase' || 'Home' }>
    and this causes all links to open a new window.

    When I change them to:
    <{if $_item[defaulttitle] != 'Knowledgebase' && 'Home' }>
    only the first link which is "Knowledgebase" stays in the browser but I also need home to do the same. Any suggests???
  2. #2
  3. CSS & JS/DOM Adept
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jul 2004
    USA (verifiably)
    Rep Power
    Welcome to DevShed Forums, MCtechsupport.

    This looks more like a server-side template system than JavaScript, but I'll try to help anyway.

    As convenient as it might be sometimes, that's not how logical operators work. You need to repeat the comparison:
    <{if $_item[defaulttitle] != 'Knowledgebase' && $_item[defaulttitle] != 'Home' }>
    P.S. Thanks for using the bbcode "code" tags.
    Spreading knowledge, one newbie at a time.

    Learn CSS. | PHP includes | HTML Validator | CSS validator

    Remember people spend most of their time on other people's sites (so don't violate web design conventions).

IMN logo majestic logo threadwatch logo seochat tools logo