Coldfusion bind problem

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?
Who is Participating?

Improve company productivity with a Business Account.Sign Up

azadisaryevConnect With a Mentor Commented:
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.

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

PanosAuthor Commented:
Get 10% Off Your First Squarespace Website

Ready to showcase your work, publish content or promote your business online? With Squarespace’s award-winning templates and 24/7 customer service, getting started is simple. Head to and use offer code ‘EXPERTS’ to get 10% off your first purchase.

PanosAuthor Commented:
PanosAuthor Commented:
PanosAuthor Commented:
PanosAuthor Commented:
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.

PanosAuthor Commented:
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) 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">

<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>
 </cfselect><br />
<cfinput name="S_Modell" type="text"  value="" maxlength="22" /><br />
<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" />

<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;"/>

PanosAuthor Commented:
Ok azadi.
I will do it like the way you say.
In a new question i will ask for the ......most elegant solution!!!
PanosAuthor Commented:
Thank you azadi for your help
regards panosms
my calling it 'not the most elegant' solution does NOT mean it is not the most effective one in the particular situation...

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.

All Courses

From novice to tech pro — start learning today.