Solved

Coldfusion bind problem

Posted on 2009-04-08
12
378 Views
Last Modified: 2013-12-24
Hello experts
I use the bind function to get the recordcount of a query without submitting a form
This works fine.the problem is that i use the same code for other forms but some form fields are missing there.So i get an error Bind failed, element not found: S_Modell_ID.
The code is:
<cfdiv bind="url:../resultscheck.cfm?S_Mobile_ID={S_Mobile_ID}&S_Modell_ID={S_Modell_ID}" ID="theDiv" style="height:20px; width:80px;"/>
I use a default value:
<cfparam name="form.S_Modell_ID" default="">but it does not solve the problem
Any help?
0
Comment
Question by:Panos
  • 8
  • 4
12 Comments
 
LVL 27

Expert Comment

by:azadisaryev
Comment Utility
using <cfparam> to set a default value for form.S_Modell_ID only does that - sets a cf variable in FORM scope.
but bindings bind to FORM FIELDS, not variables in FORM scope - you need to have an actual form field with name="S_Modell_ID" to bind to it. even a simple hidden form field will do.

but i do not understand why do you need to bind your cfdiv to a form field that does not exist in your form???
even if you cfdiv is in a cfinclude'd file and is included in various pages which have different forms with different fields - you do not need to fix the field the cfdiv is binding to. you can easily use your form element's onChange or onClick events to fire off a js function which uses ColdFusion.navigate() function to populate the cfdiv...

your resultscheck.cfm page, presumably, already has all possible url vars <cfparam>'ed...

Azadi
0
 
LVL 2

Author Comment

by:Panos
Comment Utility
0
 
LVL 2

Author Comment

by:Panos
Comment Utility
0
 
LVL 2

Author Comment

by:Panos
Comment Utility
0
 
LVL 2

Author Comment

by:Panos
Comment Utility
0
 
LVL 2

Author Comment

by:Panos
Comment Utility
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 27

Expert Comment

by:azadisaryev
Comment Utility
that 'tutorial' was dealing with submitting a cfform which is displayed inside a cfdiv.
from what i understand, you have a cfform in your page but you want to submit it to (and show search results in) another page displayed inside a cfdiv (loaded via <cfinclude>) - your form itself is NOT inside that cfdiv, right?

also, is it that you want to have different forms (with different fields) submit to the same page, or is it always only one and the same form (but maybe has different fields displayed/selected based on other fields)

in either case, using ColdFusion.navigate() function you can submit your form to (and show results in) a particular container on your page (like your cfdiv). no need for biding the cfdiv to anything - your form will post to resultscheck.cfm page, but will display it in your cfdiv.
on your resultscheck.cfm page you will have to parse submitted data to see which fields have been selected/filled in in the form, and construct your query to retrieve results based on those selections (or show an error/warning to the user if some fields which are required have not been filled in/selected).

i was originally thinking your form was a simple one with only 1-2 fields. in that case using the field's onclick/onchange events would have been fine. but with a form like on the link you posted that is not going to be a good option - with so many form fields you do not want to be re-submitting the form with a change in each one. you want the user to make all necessary selections first, then click a button which will fire off a js function that uses ColdFusion.navigate to submit your form into your cfdiv.

Azadi
0
 
LVL 2

Author Comment

by:Panos
Comment Utility
Hi azadi.
First of all i want to tell you that i found a solution from you how it works with onchange:
<cfdiv bind="url:../resultscheck.cfm?S_Mobile_ID={S_Mobile_ID}&S_Modell_ID={S_Modell_ID@change}" ID="theDiv" style="height:20px; width:80px;"/> but i will need hidden fields as you say.
The forms are not always the same but they submit to the same page.
(f.e the field S_Modell_ID is only in one form but other fields like S_price field ,S_Hersteller_ID field are in the most forms)
.......no need for binding the cfdiv to anything...:You mean that i can bind the form and not the fields?
........ it is not a good idea..... but the function in the page (mobile) is working very fine.
In the example page here what must i do to have the best working solution:
<cfform action="../Results.cfm" method="get" name="SearchForm" id="SearchForm">

Make:
<cfselect name="S_Hersteller_ID"  id="S_Hersteller_ID" onchange="getModell(this.value);">
      <option value="">All</option>
      <cfoutput query="qHersteller">
      <option value="#qHersteller.Hersteller_ID#">#qHersteller.Hersteller_Text#</option>
      </cfoutput>
 </cfselect><br />
Modell:
<cfinput name="S_Modell" type="text"  value="" maxlength="22" /><br />
Garantie:
<cfinput name="S_Garantie" type="checkbox" id="S_Garantie"value="1"  /><br />
<cfinput type="hidden" name="S_Mobile_ID" id="S_Mobile_ID" value="1" />
<input name="" type="submit" />
</cfform>

<cfdiv bind="url:../resultscheck.cfm?S_Mobile_ID={S_Mobile_ID}&S_Hersteller_ID={S_Hersteller_ID@change}&S_Modell_ID={S_Modell_ID@change}&S_Modell={S_Modell}&S_Garantie={S_Garantie.checked}" ID="theDiv" style="height:20px; width:80px;"/>

0
 
LVL 27

Accepted Solution

by:
azadisaryev earned 500 total points
Comment Utility
i see... so your resultscheck.cfm page only returns the number of results, and not the results themselves...
if so, then what you currently have is probably the best, if not most elegant, solution. you are definitely better off binding your cfdiv to all possible form fields, so the user does not actually have to click anything to see if his selections return any results.
yep, you'll just have to have all the fields your resultscheck.cfm page expects in your forms, either as actual fileds or as hidden fields.

in your code above, since your S_Modell field is a text input field, i maybe would just add @blur, or even @none, to {S_Modell} binding in the cfdiv - i.e. {S_Modell@blur} - so that the binding on the div either does not fire at all when the value in that field changes (@none - it will include the value entered in the field, but will not cause the binding to fire off when that value changes) or fires off when that field loses focus (@blur) instead of when a user clicks in that field.

Azadi
0
 
LVL 2

Author Comment

by:Panos
Comment Utility
Ok azadi.
I will do it like the way you say.
In a new question i will ask for the ......most elegant solution!!!
0
 
LVL 2

Author Closing Comment

by:Panos
Comment Utility
Thank you azadi for your help
regards panosms
0
 
LVL 27

Expert Comment

by:azadisaryev
Comment Utility
my calling it 'not the most elegant' solution does NOT mean it is not the most effective one in the particular situation...

Azadi
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

728 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

13 Experts available now in Live!

Get 1:1 Help Now