• I have a basic javascript countdown timer and want to create a shortcode to display countdowns for different dates. The shortcode I created is:
    There are [sc:countdown holiday="2015,12,25"] until Christmas!
    …and then the shortcode contains the following but doesn’t work. The javascript works, just not in the shortcode:

    <script>
    var current="NO MORE DAYS"
    var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")
    
    function countdown(yr,m,d){
    var today=new Date()
    var todayy=today.getYear()
    if (todayy < 1000)
    todayy+=1900
    var todaym=today.getMonth()
    var todayd=today.getDate()
    var todaystring=montharray[todaym]+" "+todayd+", "+todayy
    var futurestring=montharray[m-1]+" "+d+", "+yr
    var difference=(Math.round((Date.parse(futurestring)-Date.parse(todaystring))/(24*60*60*1000))*1)
    if (difference==0)
    document.write(current)
    else if (difference>0)
    document.write(difference+" days")
    }
    //enter the count down date using the format year/month/day
    countdown(2015,9,14)
    </script>
    <script type="text/javascript"> countdown(%%holiday%%)</script>

    https://www.ads-software.com/plugins/shortcoder/

  • The topic ‘Possible to get javcascript to work in shortcode?’ is closed to new replies.