Solved

Submitting to CFDIV Problem

Posted on 2011-03-23
6
756 Views
Last Modified: 2012-08-13
Hi there.  I tried to submit to a CFDIV from a CFFORM on the same page but it appears that the check box's value is always the same regardless if it is checked or not.

Can somebody help?

Thanks in advance.
<head>
<title></title>
</head>

<body>
   <form method="Post" name="FormSearch" id="FormSearch" target="SearchResult">
      <input name="Search" type="text" />
      <input name="Search2" type="checkbox" value="checkedBoxValue" />
      <input name="Search3" type="text" />
      <input name="Submit" type="button" value="SEARCH" onClick="ColdFusion.Ajax.submitForm("This");" />
   </form>
   <cfdiv id="SearchResult" bind="url:SampleDivSubmitResults.cfm?Search={Search}&Search2={Search2}&Search3={Search3}" />
</body>
</html>

Open in new window

This is what it looks like when it is checked (notice the value in search 2) This is what it looks like when it is unchecked (notice the value in search 2 is still there) This is what it looks like when it is unchecked (notice the value in search 2 is still there) This is what it looks like when it is checked (notice the value in search 2)
0
Comment
Question by:SFTProd
6 Comments
 
LVL 82

Expert Comment

by:leakim971
ID: 35202931
Try to replace with :


<input name="Search2" type="checkbox" value="checkedBoxValue" onclick="this.value = (this.checked?'checkedBoxValue':'')" />

Open in new window

0
 
LVL 52

Expert Comment

by:_agx_
ID: 35203038
the check box's value is always the same regardless if it is checked or not

That's because a checkbox's value never changes, it's state is what changes (checked or unchecked)

I'm not real familiar with the ajax stuff.  But I'm not sure there's a slick way to conditionally pass the "value" the way you want.  leakim971's suggestion worked for me, with the addition of this code

<input name="Search2" type="checkbox" value="checkedBoxValue" onclick="this.value = (this.checked?'checkedBoxValue':'')" />
...
<cfdiv id="SearchResult" bind="url:SampleDivSubmitResults.cfm?Search={Search}&Search2={Search2.value@click}&Search3={Search3}" />
0
 
LVL 39

Expert Comment

by:gdemaria
ID: 35207412

I think you should be using ColdFusion.navigate

It has the built in ability to post of form asynchronously and it allows you to provide a target (which would be the CFDIV).

I think this is a very simple way of doing what you are attempting

http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=JavaScriptFcns_24.html
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 52

Expert Comment

by:_agx_
ID: 35208551
Be sure to check the user comments at the bottom of that page.  Last time I used it, the parameter order was wrong ... which caused me some confusion at first ;-)

> I think you should be using ColdFusion.navigate

What's the goal?  Do you want to update the cfdiv only when the form is submitted OR whenever any of the form fields changes? If it's the former, then gdemaria's suggestion is the way to go. If it's the latter, then use a bind.
0
 

Author Comment

by:SFTProd
ID: 35209400
I am looking to bind multiple fields to a CFDIV. So, if the form changes in value, I would like it to submit to the CFDIV on the same page.

It is easy to bind it to a single field but I am not sure how to bind it to the whole form itself.

Thanks in advance.
0
 
LVL 11

Accepted Solution

by:
Brijesh Chauhan earned 500 total points
ID: 35369646
The first 2 post does work and you get all the form fields in the div, including the checkbox attribute.

<head>
<title></title>

<body>
   <cfform name="FormSearch" id="FormSearch">
      <cfinput name="Search" type="text" />
      <input name="Search2" type="checkbox" onclick="this.value = (this.checked?'checkedBoxValue':'')"/>
      <cfinput name="Search3" type="text" />
   </cfform>
   
<cfdiv bind="search={Search@keyup},checkbox={Search2.value@click},Search3={Search3@keyup}" id="SearchResult"/>
</body>
</html>

Open in new window

0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

PROBLEM:  How to open a cfwindow or run a function on double click of a cfgrid row. One of my clients wanted to be able to double click on a row item to get more detailed information about a transaction and to be able to modify the line items i…
Today, I was working on some optimization and spam-stopping techniques when I encountered Ben Nadel's post to reduce spam feature using Math (http://www.bennadel.com/blog/197-How-I-Stop-Spammers-On-My-ColdFusion-Blog.htm). While this method is not o…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

707 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

18 Experts available now in Live!

Get 1:1 Help Now