Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 399
  • Last Modified:

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?
0
Panos
Asked:
Panos
  • 8
  • 4
1 Solution
 
azadisaryevCommented:
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
 
PanosAuthor Commented:
0
 
PanosAuthor Commented:
0
Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

 
PanosAuthor Commented:
0
 
PanosAuthor Commented:
0
 
PanosAuthor Commented:
0
 
azadisaryevCommented:
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
 
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)
.......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
 
azadisaryevCommented:
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
 
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!!!
0
 
PanosAuthor Commented:
Thank you azadi for your help
regards panosms
0
 
azadisaryevCommented:
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 Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

  • 8
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now