Solved

Coldfusion bind problem

Posted on 2009-04-08
12
382 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
[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
  • 8
  • 4
12 Comments
 
LVL 27

Expert Comment

by:azadisaryev
ID: 24103647
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
ID: 24104293
0
 
LVL 2

Author Comment

by:Panos
ID: 24104471
0
Manage your data center from practically anywhere

The KN8164V features HD resolution of 1920 x 1200, FIPS 140-2 with level 1 security standards and virtual media transmissions at twice the speed. Built for reliability, the KN series provides local console and remote over IP access, ensuring 24/7 availability to all servers.

 
LVL 2

Author Comment

by:Panos
ID: 24104528
0
 
LVL 2

Author Comment

by:Panos
ID: 24104553
0
 
LVL 2

Author Comment

by:Panos
ID: 24104580
0
 
LVL 27

Expert Comment

by:azadisaryev
ID: 24104714
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
ID: 24104966
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
ID: 24105079
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
ID: 24105152
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
ID: 31568227
Thank you azadi for your help
regards panosms
0
 
LVL 27

Expert Comment

by:azadisaryev
ID: 24105230
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

735 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