Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Submitting to CFDIV Problem

Posted on 2011-03-23
6
Medium Priority
?
770 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 2000 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

604 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