![]() |
| Holding a checkbox value on a recursive submit |
|
jamie
HostMySite Sales Rep
![]()
|
Ok, my next question about checkboxes. I have a form that searching a database based off values in several checkboxes. I.e.
So with the above type of search, I have the form returning the information found to itself, which displays the relevant information with a CFOutput statement. However, when it does this the checkboxes no longer hold a check. How can I preserve the checkbox state and re-create it on the page when it reloads? |
||||||||||||||
|
|
|||||||||||||||
|
Josh
Forum Regular
|
isn't this a viewstate thing? Jamie, you should be using ASP.NET
|
||||||||||||
|
|
|||||||||||||
|
jamie
HostMySite Sales Rep
![]()
|
Nope, not going to ASP.NET. I'm using CF + MySQL, and Javascript to supplement if I have to.
|
||||||||||||
|
|
|||||||||||||
|
byron
Forum Admin
|
<input type="checkbox" name="red" value=1<cfif isDefined("form.red") and form.red eq 1> CHECKED</cfif>>
I believe with view state and asp.NET this is a built in part of the checkbox control, so you wouldn't be adding this line. Someday I'll go back to the dark side and figure out .NET |
||||||||||||
|
|
|||||||||||||
|
Josh
Forum Regular
|
I wasn't actually suggesting that you move to .NET... sorry. In .NET viewstate is tracked automatically for the sake of postbacks and what not. They figured out that everybody was doing at least a little, and in some cases some extensive, tracking of viewstate so they worked in an automated process just for this.
Byron got this for ya |
||||||||||||
|
|
|||||||||||||
|
jamie
HostMySite Sales Rep
![]()
|
Thanks for the push in the right direction. The cfif statement actually ended up being this:
|
||||||||||||||
|
|
|||||||||||||||
|
jamie
HostMySite Sales Rep
![]()
|
Two things:
1. The last three posts were deleted by me. I got rid of the first two because they didn't contribute to the thread and they were needlessly arguing. Please refrain from doing that again (you both know who you are). The third post in the series was referencing the others, so it became kinda senseless once I removed them (sorry Byron). 2. Now, back to the point. My code now looks something like this:
However it's not consistently saving the checkbox information. If you click on "white" then it is saved, however if you click on 'white' and 'blue' they are both cleared. A copy of this script can be found at http://mtgotradingpost.com/mycards.cfm Suggestions are welcome! |
||||||||||||||
|
|
|||||||||||||||
|
steve
HostMySite Developer
|
Jamie,
Your checkbox fields are named the same so if they are both checked form.color will be '1,1' If you give the form fields separate names you will be able to distinguish one from the other. -Steve |
||||||||||||
|
|
|||||||||||||
|
Josh
Forum Regular
|
ah ha you are correct. Good eye. I looked that over and didn't catch it.
|
||||||||||||
|
|
|||||||||||||
| checkboxes |
|
kbrocx
|
If you actually WANT to pass your checkboxes in a list like that then you could do <cfif isDefined('form.color') And ListFind('#form.color#','white')>Checked</cfif>
|
||||||||||||
|
|
|||||||||||||
| Holding a checkbox value on a recursive submit |
|
||
|



