Bind a textfield with a checkbox

Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.

  1. #1

    Default Bind a textfield with a checkbox

    Hi all, is it possible to bind a textfield with a checkbox. What I am trying
    to do is, if the checkbox is selected todays date will display in the textbox
    next to it. If the checkbox is cleared the date is deleted.

    Thanks in advance for your help.

    EdmondsM Guest

  2. Similar Questions and Discussions

    1. Bind Attribute in CheckBox -->Help
      Hello Everyone, I attented a great presentation yesterday by Macromedia Canada. I need a little help regarding the BIND attribute. I am doing...
    2. bind to a checkbox
      I have a tabbed flash form. the final tab is a summary page of the previous two tabbed pages. The second page lists 10 check boxes. If the...
    3. Howto bind CheckBox to the datagrid/ Then update the database field when the checkbox is clicked.
      I am trying to update the database field when the checkbox is clicked. I am trying to modified the following solution but.. got stuck on the...
    4. How to bind checkbox to one of the values of a datagrid
      Hello All, I hope someone can enlighten me, all of the examples and posts Ihave read and sifted through doesn't pertain to what i wouldlike to do...
    5. how to bind data to checkbox in datagrid
      hi i have a datagrid and one colume is a bool if i use a normal asp:BoundColumn is shows as true or false and i want it to show as a checkbox but...
  3. #2

    Default Re: Bind a textfield with a checkbox

    You'd do this with Javascript.
    Velvett Fog Guest

  4. #3

    Default Re: Bind a textfield with a checkbox

    <form action="">
    <input type="checkbox" name="chktest" value="1" onClick="if
    (this.checked){nxtdt = new Date() ;nxtdtstrng = (nxtdt.getMonth()+1) +
    '/' + nxtdt.getDate() + '/' + nxtdt.getFullYear()
    ;this.form.testdt.value=nxtdtstrng}else{this.form. testdt.value=this.form.testdt.defaultValue}"><inpu t
    type="text" name="testdt">
    </form>

    HTH

    --
    Tim Carley
    [url]www.recfusion.com[/url]
    [email]info@NOSPAMINGrecfusion.com[/email]
    Mountain Lover Guest

  5. #4

    Default Re: Bind a textfield with a checkbox

    Hey Tim, this is beautiful. The only draw back is that it give me a the
    following message.

    Illegal usage of actionscript.
    The following actionscript commands are not allowed: "import, new, delete,
    createChild, loadmovie, duplicateMovieClip, AttachMovie, registerclass,
    createTextField, __proto__".

    I think this is to to the following line of code {nxtdt = new Date() . Is
    there anyway around this?? Where can I get more information on Actionscripts.

    Thanks again.

    EdmondsM Guest

  6. #5

    Default Re: Bind a textfield with a checkbox

    You didn't say you were using Flash forms. Can't help you there. The
    Javascript given works in all html forms.

    --
    Tim Carley
    [url]www.recfusion.com[/url]
    [email]info@NOSPAMINGrecfusion.com[/email]
    Mountain Lover Guest

  7. #6

    Default Re: Bind a textfield with a checkbox

    You might want to look at using the calendar cfinput object.
    Or
    You could in theory use something like this... It isn't perfect, but I think
    it does what you want.

    <cfinput type="checkbox" id="senior" name="checky" value="1" label="Checky
    Box" />
    <cfinput type="text" name="textBoxName" bind="{(checky.selected == undefined)?
    '': textBoxName.enabled}" />


    Typheous Guest

  8. #7

    Default Re: Bind a textfield with a checkbox

    I don't know about flash forms, maybe you can't use this kind of javascript
    with them. But if the problem really is with using "new", then you could try
    this: at page load, set a hidden input's value as today's date in the format
    you want (I called it dtholder below). Then modify the javascript that Mountain
    Lover gave, as below:



    <input type="hidden" name="dtholder" value="#DateFormat(Now(), 'mm/dd/yyyy')#">
    <input type="checkbox" name="chktest" value="1" onClick="if

    (this.checked){this.form.testdt.value=this.form.dt holder.value}else{this.form.te
    stdt.value=this.form.testdt.defaultValue}">

    <input type="text" name="testdt">

    mkane1 Guest

  9. #8

    Default Re: Bind a textfield with a checkbox

    Not sure if this will work as I'm away from my dev environment and can't test,
    but

    <cfoutput>
    <cfinput type="checkbox" name="myChk" onchange="{(myChk.selected) ? myTxt.text
    = '#DateFormat(Now(), ""mm/dd/yyyy"")#' : ''}">
    </cfoutput>
    <cfinput type="text" name="myTxt">

    I will test this when I can.

    Ken

    The ScareCrow Guest

  10. #9

    Default Re: Bind a textfield with a checkbox

    Hi The ScareCrow and mkane1, thanks for your help. ScareCrow, you code did not
    porduce the results that I was after. MKane, you code did but it still will
    not work in <cfform format=flash>. May this is not possible to do within a
    flash page?? It works fine in HTML and XML however.

    EdmondsM Guest

  11. #10

    Default Re: Bind a textfield with a checkbox

    Attached is a working example

    Ken

    <cfform action="" method="POST" name="form1" format="Flash" timeout="300"
    preservedata="Yes">
    <cfinput type="Checkbox" name="myChk" visible="Yes" enabled="Yes">
    <cfoutput>
    <cfinput type="Text"
    name="myTxt"
    bind="{(myChk.selected) ? myTxt.text='#DateFormat(Now(),
    'mm/dd/yyyy')#' : ''}"
    required="No"
    visible="Yes"
    enabled="Yes">
    </cfoutput>
    </cfform>

    The ScareCrow Guest

  12. #11

    Default Re: Bind a textfield with a checkbox

    Thanks The ScareCrow, this worked beautiful
    EdmondsM Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139