ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

if statements not executing in javascript tag

June 27, 2008 12:46pm

Subscribe [1]
  • #1 / Jun 27, 2008 12:46pm

    this is so weird. i can’t figure it out! here’s a snippet of my code.

    {exp:weblog:entries weblog="case_studies" limit="1" disable="member_data|trackbacks|pagination" dynamic="on"}
    
    {if cs_ss_image2 || cs_ss_image3 || cs_ss_image4 || cs_ss_image5 }
    < script type="text/javascript" language="javascript" >
    
    doclay = (document.layers)? true : false
    docall = (document.all)? true : false
    docget = (document.getElementById)? true : false
    
    thisImg = 0
    {if cs_ss_image2 && cs_ss_image3 && cs_ss_image4 && cs_ss_image5 }
    imgCt = 4
    {if:elseif (cs_ss_image2 && cs_ss_image3 && cs_ss_image4) && (cs_ss_image5 == "")}
    imgCt = 3
    {if:elseif (cs_ss_image2 && cs_ss_image3) && (cs_ss_image4 == "") && (cs_ss_image5 == "")}
    imgCt = 2
    {if:elseif cs_ss_image2 && (cs_ss_image3 == "") && (cs_ss_image4 == "") && (cs_ss_image5 == "")}
    imgCt = 1
    {if:else}
    imgCt = 0
    {/if}
    baseCt = 0
    
    ....
    
    < / script >
    {/if}

    there are other if statements in the javascript code too but i cut them out for brevity. when i look at the source of my page, the if statements with the rendered custom field variables are dumping to the html. they aren’t rendered. BUT if statements outside of the

    < script type="text/javascript" language="javascript" >
    tag render fine! if i delete the
    < script type="text/javascript" language="javascript" >
    tag the if statements are rendered. why would this
    < script type="text/javascript" language="javascript" >

    be causing if statements not to render? i’m so stumped.

    BTW, this is an article page so dynamic is turned on so that exp:weblog:entries grabs the proper content.

    p.s. spaces in the javascript tags are there because the forum removed the tags otherwise.

  • #2 / Jun 27, 2008 12:56pm

    oh my god, i found the answer by hitting google with 10 different queries.

    http://expressionengine.com/wiki/Hidden_Configuration_Variables/#protect_javascript

    you know, i can’t help but think that this should be turned off automatically or it should be documented up front in the “getting started” tutorial.

    i guess you can close this one 😊

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases