Solved

<cvdiv bind="url........." and <cfinput type checkbox problem

Posted on 2009-04-02
12
554 Views
Last Modified: 2013-12-24
Hello experts
I use this code:
<cfparam name="Url.S_Leasing" default="">
<cfdiv bind="url:../resultscheck.cfm?S_Leasing={S_Leasing}" ID="theDiv" style="height:20px; width:80px;"/>
<cfform>
<cfif  url.S_Leasing EQ 1 > 
    <cfset checkleasing = 'yes'>
    <cfelse>
     <cfset checkleasing = 'no'>
     </cfif>
    <cfinput name="S_Leasing" id="S_Leasing" type="checkbox"   checked="#checkleasing#" value="1" />
</cfform>
and using the cfdebug i see that when the checkbox is not checked value 1 is passed to the url:
Coldfusion Ajax Logger:
info:http: Replaced markup for element: theDiv

info:http: HTTP GET ../resultscheck.cfm?S_Leasing=1&_cf_containerId=theDiv&_cf_nodebug=true&_cf_nocache=true&_cf_clientid=8E407863AA052BD8A1E25ADF06B0023F&_cf_rc=0

info:http: Replacing markup for element: theDiv from URL ../resultscheck.cfm?S_Leasing=1 with params _cf_containerId=theDiv

info:LogReader: LogReader initialized

info:global: Logger initialized
Any help?
0
Comment
Question by:Panos
  • 8
  • 4
12 Comments
 
LVL 27

Expert Comment

by:azadisaryev
ID: 24051310
by default, allbindings are bound to the VALUE attribute of the element. since the value of VALUE attribute of your checkbox is 1, that's what the binding returns, disregarding if the checkbox is checked or not.

try this:
<cfdiv bind="url:../resultscheck.cfm?S_Leasing={S_Leasing.selected}" ID="theDiv" style="height:20px; width:80px;"/>

mind you, that will likely request the url with S_Leasing=true or S_Leasing=false url parameter - so make sure your resultscheck.cfm can react properly to true/false as url.S_Leasing value...

Azadi
0
 
LVL 2

Author Comment

by:Panos
ID: 24051800
Hi azadi
Here  is a part of my resultcheck.cfm page.
Can you help me?
<cfquery name="WADAdboartikel" datasource="#request.dsn#">
SELECT  *
FROM artikel
WHERE (0=0
<cfif isdefined("Url.S_Leasing") >
<cfif Url.S_Leasing NEQ "">     
  AND  Leasing = <cfqueryparam value="#URL.S_Leasing#"  cfsqltype="cf_sql_tinyint">
       </cfif>
       </cfif>
   )
</cfquery>
 
<cfoutput>#WADAdboartikel.RecordCount#</cfoutput>
0
 
LVL 2

Author Comment

by:Panos
ID: 24052126
Something else.
Is there another way to get the recortcount witout submutting the form?
0
 
LVL 27

Expert Comment

by:azadisaryev
ID: 24056200
oops... the checkbox's attribute to be used in the binding should be .checked, not .selected...

here's the full working code:

<!--- form page --->
<cfparam name="Url.S_Leasing" default="0"><!--- default it to 0 instead of empty string --->
<cfdiv bind="url:../resultscheck.cfm?S_Leasing={S_Leasing.checked}" ID="theDiv" style="height:20px; width:80px;"/>
<cfform>
    <cfinput name="S_Leasing" id="S_Leasing" type="checkbox" checked="#yesnoformat(URL.S_Leasing)#" value="1" />
</cfform>

<!--- resutscheck.cfm --->
<cfparam name="url.S_Leasing" default="0"><!--- cfparam this on this page, too! --->
<cfquery name="WADAdboartikel" datasource="#request.dsn#">
SELECT  COUNT(*) AS ttlcount
FROM artikel
WHERE Leasing = <cfqueryparam value="#val(URL.S_Leasing)#"  cfsqltype="cf_sql_tinyint">
</cfquery>
<cfoutput>#WADAdboartikel.ttlcount#</cfoutput>

Azadi
0
 
LVL 27

Expert Comment

by:azadisaryev
ID: 24056207
as for getting the recordcount without submitting the form:
yes, there are multiple ways to do it, and i think you know all of them. at least you used most of these ways in the other things you are doing and posting questions about :)

js proxy to a cfc and binding directly to a cfc which returns the recordcount are 2 of these ways.

if i am misunderstanding what you mean by 'another way to get the recortcount witout submutting the form' - please clarify.

Azadi
0
 
LVL 2

Author Comment

by:Panos
ID: 24057444
Hi azadi.
I'm asking if there is another way because i don't know which of these function is  faster.
Now for the solution you posted:
As is see it is passing true and false in url.
In database the values are 0 and 1.
How can i handle this in the resultcheck page.
0
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
LVL 2

Author Comment

by:Panos
ID: 24057494
Is this OK?
<cfparam name="url.S_Leasing" default="0">
<cfif Url.S_Leasing  EQ true>
  <cfset S_Leasing = 1 >
  <cfelse>
  <cfset S_Leasing = 0 >
  </cfif>

......
<cfif S_Leasing EQ 1 >     
  AND  Leasing = <cfqueryparam value="1"  cfsqltype="cf_sql_tinyint">
       </cfif>

In resultcheckpage
0
 
LVL 2

Author Comment

by:Panos
ID: 24057502
Notice that if the value is 0 in database i want all the results (0 and 1)
0
 
LVL 27

Accepted Solution

by:
azadisaryev earned 500 total points
ID: 24057737
you mean it did not work as it is?
it worked fine with passing 'true' or 'false' value in the url... my db is mysql and the field type is tinyint as well...

oh... oooops.... i have no idea how that val() function got in there... the WHERE clause in your query should just be:

WHERE Leasing = <cfqueryparam value="#URL.S_Leasing#"  cfsqltype="cf_sql_tinyint">

without val() in the value...

sorry! :)

Azadi
0
 
LVL 2

Author Comment

by:Panos
ID: 24057865
Ok azadi it is working now
0
 
LVL 2

Author Comment

by:Panos
ID: 24057869
I will come back with a question about binding values from a checkboxgroup
0
 
LVL 2

Author Closing Comment

by:Panos
ID: 31565844
Thank you very much for your help
regards
Panos
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Forbidden errors 5 123
Using random iterations in password hashing.  Good or Bad? 4 76
JVM encoding. How to change encoding. 27 85
Connect to MS-SQL server from Linux/PHP 8 81
Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now