Uncheck checkbox dynamically

Discussion in 'Programming' started by dallasmc16, Apr 11, 2009.

  1. #1
    Hi,

    I am fairly new to this so need a small bit of help.

    I am trying to have a checkbox become dynamically unchecked after a
    certain date, allowing our business' specials to finish and not show at
    the special price anymore.

    I have played around for a bit but seem to be having some problems. It
    is date dependant, so if the date expires so should the special price
    and uncheck the box.

    Some of the code I'm looking at is as follows for the specification of
    the date:

    <TD nowrap><B>End Date*:</TD>
    <TD bgcolor=ffffff><input type="text" name="itemend"
    value="#dateFormat(itemend,'dddd, dd mmmm yyyy')#" ControlSize =
    "80"></td>

    And the checkbox that I want to have unchecked if the date is passed:

    <td><input type="checkbox" name="IO_#itemoptionid#_itemsale"
    value="1"<cfif itemsale> checked</cfif>
    <font color="#fontcolor#">YES @ $ <input
    type="text" name="IO_#itemoptionid#_itemsaleprice"
    value="#Decimalformat(itemsaleprice)#" size="5" style="text-align:
    right;" #readonly#></td>

    Also if there is no data in the end date section then this shouldn't mke any difference as the item shouldn't be checked.

    Is there an easy way to do this?

    Cheers in advance,


    Dallas
     
    dallasmc16, Apr 11, 2009 IP
  2. robhustle

    robhustle Peon

    Messages:
    98
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    <cfset itemoptionid = 1>
    <cfset itemsaleprice = 20.00>


    <cfset _date = now()>
    <cfset _expired = dateadd("h",-1,_date)>
    <cfset itemsale = iif(_date lt _expired,true,false)>

    <cfset _value = dateFormat(_date,'dddd, dd mmmm yyyy')>

    <cfoutput>
    <input type="text" name="itemend" value="#dateFormat(_value,'dddd, dd mmmm yyyy')#" ControlSize="80"><br>

    <input type="checkbox" name="IO_#itemoptionid#_itemsale" value="1"<cfif itemsale> checked</cfif>>
    YES @ $
    <input type="text" name="IO_#itemoptionid#_itemsaleprice" value="#Decimalformat(itemsaleprice)#" size="5" style="text-align:right;" <cfif not(itemsale)>disabled</cfif>>
    </cfoutput>
     
    robhustle, Apr 30, 2009 IP
  3. zain654321

    zain654321 Peon

    Messages:
    202
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    <html>

    <head>
    <script type="text/javascript">
    function check(){
    var x=document.forms.myForm
    x[0].checked=true
    }

    function uncheck(){
    var x=document.forms.myForm
    x[0].checked=false
    }
    </script>
    </head>

    <body>

    <form name="myForm">
    <input type="checkbox" value="on">
    <input type="button" onclick="check()" value="Check Checkbox">
    <input type="button" onclick="uncheck()" value="Uncheck Checkbox">
    </form>

    </body>
    </html>
     
    zain654321, Jul 8, 2009 IP