Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

how to make this in coldfusion

New Here ,
Oct 28, 2010 Oct 28, 2010

hi we just have  countdown clock placed in our website , but users are asking that to change date they always needs to ask us to change for certain date .

We usally changes date in cfm page and deployed in production  so that countdown is working, but users are asking now that is there is any way to give them the admin privalages so that they can change date to that timer.

We have any solution for this in coldfusion.

we have javascript code in .cfm page

Thanks.

TOPICS
Getting started
1.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Oct 28, 2010 Oct 28, 2010

Probably at least a dozen different ways, depending on what your code looks like and what you really want to do.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 28, 2010 Oct 28, 2010

<script language="JavaScript1.2">

function setcountdown(theyear,themonth,theday,thehour,themin,thesec){

yr=theyear;mo=themonth;da=theday;hr=thehour;min=themin;sec=thesec

}

//////////CONFIGURE THE COUNTDOWN SCRIPT HERE//////////////////

//STEP 1: Configure the countdown-to date, in the format year, month, day, hour(0=midnight,23=11pm), minutes, seconds:
setcountdown(2010,10,24,17,00,00)

//STEP 2: Change the two text below to reflect the occasion, and message to display on that occasion, respectively
var occasion=""
var message_on_occasion="Countdown to Case Ready Pork & Grind Catalog 79 Transmission"

//STEP 3: Configure the below 5 variables to set the width, height, background color, and text style of the countdown area
var countdownwidth='100%'
var countdownheight='100px'
var countdownbgcolor='#efefef'
var opentagsi='<div style="font-size: 16px; color: Black; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;" align="center"><b>'
var closetagsi='</b></div>'
var opentags='<div style="font-size: 16px; color: Blue; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;" align="center"><b>'
var closetags='</b></div>'
var opentags2='<div style="font-size: 14px; color: Red; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;" align="center"><b>'
var closetags2='</b></div>'

//////////DO NOT EDIT PAST THIS LINE//////////////////

var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")
var crosscount=''

function start_countdown(){
if (document.layers)
document.countdownnsmain.visibility="show"
else if (document.all||document.getElementById)
crosscount=document.getElementById&&!document.all?document.getElementById("countdownie") : countdownie
countdown()
}

if (document.all||document.getElementById)
document.write('<span id="countdownie" style="width:'+countdownwidth+'; background-color:'+countdownbgcolor+'"></span>')

window.onload=start_countdown


function countdown(){
var today=new Date()
var todayy=today.getYear()
if (todayy < 1000)
todayy+=1900
var todaym=today.getMonth()
var todayd=today.getDate()
var todayh=today.getHours()
var todaymin=today.getMinutes()
var todaysec=today.getSeconds()
var todaystring=montharray[todaym]+" "+todayd+", "+todayy+" "+todayh+":"+todaymin+":"+todaysec
futurestring=montharray[mo-1]+" "+da+", "+yr+" "+hr+":"+min+":"+sec
dd=Date.parse(futurestring)-Date.parse(todaystring)
dday=Math.floor(dd/(60*60*1000*24)*1)
dhour=Math.floor((dd%(60*60*1000*24))/(60*60*1000)*1)
dmin=Math.floor(((dd%(60*60*1000*24))%(60*60*1000))/(60*1000)*1)
dsec=Math.floor((((dd%(60*60*1000*24))%(60*60*1000))%(60*1000))/1000*1)
//if on day of occasion
if(dday<=0&&dhour<=0&&dmin<=0&&dsec<=1&&todayd==da){
if (document.layers){
document.countdownnsmain.document.countdownnssub.document.write(opentags+message_on_occasion+closetags)
document.countdownnsmain.document.countdownnssub.document.close()
}
else if (document.all||document.getElementById)
crosscount.innerHTML=opentags+message_on_occasion+closetags
return
}
//if passed day of occasion
else if (dday<=-1){
if (document.layers){
document.countdownnsmain.document.countdownnssub.document.write(opentags+"Occasion already passed! "+closetags)
document.countdownnsmain.document.countdownnssub.document.close()
}
else if (document.all||document.getElementById)
crosscount.innerHTML=opentags+"Occasion already passed! "+closetags
return
}
//else, if not yet
else{
if (document.layers){
document.countdownnsmain.document.countdownnssub.document.write(opentags+"Countdown to "+closetags+opentags2+" "+dday+ " days, "+dhour+" hours, "+dmin+" minutes, and "+dsec+" seconds left<br>"+occasion+closetags2)
document.countdownnsmain.document.countdownnssub.document.close()
}
//executed*
else if (document.all||document.getElementById)
crosscount.innerHTML=opentags+"REMAINING DAYS "+closetags+opentags2+" "+dday+ " days, "+dhour+" hours, "+dmin+" minutes, and "+dsec+" seconds left<br>"+occasion+closetags2
}
setTimeout("countdown()",1000)
}
</script>
<ilayer id="countdownnsmain" width=&{countdownwidth}; height=&{countdownheight}; bgColor=&{countdownbgcolor}; visibility=hide><layer id="countdownnssub" width=&{countdownwidth}; height=&{countdownheight}; left=0 top=0></layer></ilayer>

the above is the code we paste din cfm age and now my question is how to give user a way to change date and time so that they will change themselves with out requesting us to make change everytime they need to change date and time.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Oct 28, 2010 Oct 28, 2010
LATEST

kirannaga wrote:

the above is the code we paste din cfm age and now my question is how to give user a way to change date and time so that they will change themselves with out requesting us to make change everytime they need to change date and time.

Do you know enough about web application programming to design an HTML page where users could provide some dynamic content that is then displayed in some type of custom HTML?

If so, then the same concepts apply here.  Some relevant portions of the above JavaScript would be replaced with some type of dynamic variable and you would create some type of User Interface where users can define the value(s) of those dynamic elements.

A super simple example that would probably be pretty useless in any real world scenario.

dynamicCountDown.cfm

<cfparam name="url.year" value="2004">

<cfparam name="url.month" value="10">
<cfparam name="url.day" value="24">
<cfparam name="url.hour" value="17">
<cfparam name="url.minute" value="00">
<cfparam name="url.second" value="00">

<cfoutput>

<script language="JavaScript1.2">

function setcountdown(theyear,themonth,theday,thehour,themin,thesec){

yr=theyear;mo=themonth;da=theday;hr=thehour;min=themin;sec=thesec

}

//////////CONFIGURE THE COUNTDOWN SCRIPT HERE//////////////////

//STEP 1: Configure the countdown-to date, in the format year, month, day, hour(0=midnight,23=11pm), minutes, seconds:

setcountdown(#url.year#,#url.month#,#url.day#,#url.hour#,#url.minute#,#url.second#)

//STEP 2: Change the two text below to reflect the occasion, and message to display on that occasion, respectively

var occasion=""

var message_on_occasion="Countdown to Case Ready Pork & Grind Catalog 79 Transmission"

//STEP 3: Configure the below 5 variables to set the width, height, background color, and text style of the countdown area

var countdownwidth='100%'

var countdownheight='100px'

var countdownbgcolor='##efefef'

var opentagsi='<div style="font-size: 16px; color: Black; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;" align="center"><b>'

var closetagsi='</b></div>'

var opentags='<div style="font-size: 16px; color: Blue; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;" align="center"><b>'

var closetags='</b></div>'

var opentags2='<div style="font-size: 14px; color: Red; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;" align="center"><b>'

var closetags2='</b></div>'

//////////DO NOT EDIT PAST THIS LINE//////////////////

var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","No v","Dec")

var crosscount=''

function start_countdown(){

if (document.layers)

document.countdownnsmain.visibility="show"

else if (document.all||document.getElementById)

crosscount=document.getElementById&&!document.all?document.getElementB yId("countdownie") : countdownie

countdown()

}

if (document.all||document.getElementById)

document.write('<span id="countdownie" style="width:'+countdownwidth+'; background-color:'+countdownbgcolor+'"></span>')

window.onload=start_countdown


function countdown(){

var today=new Date()

var todayy=today.getYear()

if (todayy < 1000)

todayy+=1900

var todaym=today.getMonth()

var todayd=today.getDate()

var todayh=today.getHours()

var todaymin=today.getMinutes()

var todaysec=today.getSeconds()

var todaystring=montharray[todaym]+" "+todayd+", "+todayy+" "+todayh+":"+todaymin+":"+todaysec

futurestring=montharray[mo-1]+" "+da+", "+yr+" "+hr+":"+min+":"+sec

dd=Date.parse(futurestring)-Date.parse(todaystring)

dday=Math.floor(dd/(60*60*1000*24)*1)

dhour=Math.floor((dd%(60*60*1000*24))/(60*60*1000)*1)

dmin=Math.floor(((dd%(60*60*1000*24))%(60*60*1000))/(60*1000)*1)

dsec=Math.floor((((dd%(60*60*1000*24))%(60*60*1000))%(60*1000))/1000*1 )

//if on day of occasion

if(dday<=0&&dhour<=0&&dmin<=0&&dsec<=1&&todayd==da){

if (document.layers){

document.countdownnsmain.document.countdownnssub.document.write(openta gs+message_on_occasion+closetags)

document.countdownnsmain.document.countdownnssub.document.close()

}

else if (document.all||document.getElementById)

crosscount.innerHTML=opentags+message_on_occasion+closetags

return

}

//if passed day of occasion

else if (dday<=-1){

if (document.layers){

document.countdownnsmain.document.countdownnssub.document.write(openta gs+"Occasion already passed! "+closetags)

document.countdownnsmain.document.countdownnssub.document.close()

}

else if (document.all||document.getElementById)

crosscount.innerHTML=opentags+"Occasion already passed! "+closetags

return

}

//else, if not yet

else{

if (document.layers){

document.countdownnsmain.document.countdownnssub.document.write(openta gs+"Countdown to "+closetags+opentags2+" "+dday+ " days, "+dhour+" hours, "+dmin+" minutes, and "+dsec+" seconds left<br>"+occasion+closetags2)

document.countdownnsmain.document.countdownnssub.document.close()

}

//executed*

else if (document.all||document.getElementById)

crosscount.innerHTML=opentags+"REMAINING DAYS "+closetags+opentags2+" "+dday+ " days, "+dhour+" hours, "+dmin+" minutes, and "+dsec+" seconds left<br>"+occasion+closetags2

}

setTimeout("countdown()",1000)

}

</script>

<cfoutput>

Then request this in a browser with a URL like this.  http://www.somedomain.com/dynamicCountDown.cfm?year=2100&month=1&day=1&hour=12&minute=15&second=30

P.S. I note that at one time, this was written as a dynamic JavaScript function which could be called with dynamic values, but it looks like that capability has been removed by your organization hard coding values into the function!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources