Coldfusion preFill Form checkbox

I know this is easy, but so far I have not been able to get this to work. All I want to do is preFill a checkbox in a cfform.

on my search page I have this checkbox  

<input type="checkbox" name="foreclosure" value="yes">Foreclosure

and when I submit the form to the action page "results" page, I have the same search form there so you can filter results/adjust search query. I want to preFill the checkbox above.

This is what I tried and it doesnt work:

<cfif IsDefined("url.Foreclosure") and len(trim(url.Foreclosure))>
  <cfset form.Foreclosure = url.Foreclosure>
</cfif>

<!---form prefill Foreclosure--->
<cfif isDefined("Form.Foreclosure")>
  <cfset CLIENT.Foreclosure = Form.Foreclosure>
  <cfset prefillForeclosure = Form.Foreclosure>
  <cfelseif isDefined("CLIENT.lastForeclosure")>
  <cfset prefillForeclosure = CLIENT.lastForeclosure>
  <cfelse>
  <cfset prefillForeclosure = " ">
</cfif>


Can someone tell me where I went wrong?
Thanks! any help is appreciated.
Bang-O-MaticAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

gdemariaCommented:
Don't know what all that stuff is with the client variable and such, I would remove it.
All you want to do is set the checked attribute if the variable is yes

<input type="checkbox" name="foreclosure" value="yes" <cfif form.foreclosure is "yes">checked</cfif> >Foreclosure
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Bang-O-MaticAuthor Commented:
Works perfect....Thank you!!
0
_agx_Commented:
(no points...)

> <cfif IsDefined("url.Foreclosure") and len(trim(url.Foreclosure))>
>  <cfset form.Foreclosure = url.Foreclosure>

Nothing to do with your question, but ... is there a reason you need use both the URL and FORM scope? If both pages are search forms (only), just use <form method="GET"...> on both. Then there's no need to copy stuff from the URL to FORM scope.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ColdFusion Language

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.