Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Form reset problem

Guest
Jan 31, 2009 Jan 31, 2009
Hi all,

I have a cfform containing 3 related cfselects (i.e. bind parameters connecting them), and it all works fine. However, I just noticed one problem: the form contains a Reset button to clear all of the form fields, which it does, but when the first cfselect is reset to it's first option, the bindings are not re-triggered so the other two cfselects do not contain the correct options. I tried adding an onreset="document.myform.firstselectid.onchange();" to the cfform tag, but that didn't work (throws a js error). BTW, I'm testing all of this in IE7 since that's what my client uses.

Anyone know how I can get the bindings to update when the form is reset?

Thanks,
Russ
901
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 31, 2009 Jan 31, 2009
What are these bindings?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 31, 2009 Jan 31, 2009
Hi Dan,

They are cfc bindings, and I guess I really have two questions. The particular problem I'm having now is just getting the change of selected option (by the Reset button) in cfselect1 to trigger binding updates in cfselect 2 and 3. However, I also have times where I'd just like to tell a cfselect to refresh it's own binding. I find cfc bindings to be very convenient, so that's what I need info for.

Thanks for your help,
Russ
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 31, 2009 Jan 31, 2009
cfc's live on the server. reset buttons do things on the client. Hence your problem.

You could always do things the way I do. Instead bindings, I use the appropriate code to get the data I need. Could be cfinvoke, cfobject, cfquery, whatever. Then I use the toScript tag to convert them to js variables. This means they are always available to the client.

Other people do stuff with ajax.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 31, 2009 Jan 31, 2009
Clearly I have not explained the problem well enough, since the fact that I'm binding to cfcs has nothing to do with the problem. Here's a simplified version of the relevant code:

<cfselect name="Type" id="Type" bind="cfc:MyCFC.GetTypes()" bindonload="yes" />
<cfselect name="Manu" id="Manu" bind="cfc:MyCFC.GetManus({Type})" />
<cfselect name="Model" id="Model" bind="cfc:MyCFC.GetModels({Type@none},{Manu})" />

When the user selects a Type from the first list, the Manu list uses it's binding to get the associated manufacturers and then the Model list uses it's binding to get the models for that type and manufacturer. It works just fine (has for a long time).

The cfform has a reset button (<input name="Reset" type="reset" value="Clear Form">), and when you click it to reset the form, it does just that, setting each cfselect to it's first option. However, the fact that the Type cfselect got reset to it's first option does not cause the Manu and then Models cfselects to refresh from their bindings like they would if the user had selected the first Type option. That is the problem.

I had hoped that simply following the reset with a js call to document.myform.Type.onchange(); would initiate the refresh, but document.myform.Type.onchange turns out to be null, so no go.

I'm aware of an undocumented js function ColdFusion.Bind.assignValue that I've seen used for refreshing a cfselect that binds to a js function, but I have not seen any use of it when binding to a cfc.

Your thoughts?

Thanks,
Russ
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 31, 2009 Jan 31, 2009
Hmmm...when you say that "Other people do stuff with ajax.", you do realize that binding to a cfc like in the code above establishes an ajax connection between the select and the cfc, right?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 02, 2009 Dec 02, 2009
LATEST

I'm having the same problem.  Did you ever find a way to get the bind to refresh?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources