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

Bind in form works with cfinput, how to with cfselect and a href

Guest
Jul 01, 2012 Jul 01, 2012

Copy link to clipboard

Copied

Hi all

This code workks binding a cfinput in an HTML cfform:

Name:<cfinput type="text" name="FIRSTNAME" label="Name" required="yes" width="150" bind="{UsersGrid.FIRSTNAME}" >

However this href doesn't seem to bind correctly:

<a  href="http://www.google.com/search?hl=en&output=search&sclient=psy-ab&q={UsersGrid.COMPANY}&btnK=" bind="{UsersGrid.COMPANY}">Google.com</a>

This cfselect doesn't either:
Department: <cfselect name="DEPARTMENT1" width="100" size="1" label="Department" required="yes" bind="UsersGrid.DEPARTMENT1">
<option></option><cfoutput query="dNames"><option value="#DEPARTMENTIDS#">#DEPARTMENTNOM#</option></cfoutput>
</cfselect> 

How can I make them both work? Thank you

Views

5.8K

Translate

Translate

Report

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

correct answers 1 Correct answer

Engaged , Jul 02, 2012 Jul 02, 2012

Excellent!  Now we'll try adding the cfselect.  Could you try this?

<cfajaxproxy bind="javascript:myHandler({UsersGrid.COMPANY},{UsersGrid.SECTORS1})" />

<script type="text/javascript">

  function myHandler(COMPANY,SECTORS1) {

      //update the link's href

      document.getElementById('myLink').href = 'http://www.coldfusion.com?q=' + COMPANY;

      //update SECTORS1's selected

      var theField = document.getElementById('SECTORS1');

      for(var i=0; i<theField.options.length; i++) {

          if(the

...

Votes

Translate

Translate
Engaged ,
Jul 03, 2012 Jul 03, 2012

Copy link to clipboard

Copied

Hi goodychurro1,

Just add this grid column: <cfgridcolumn name="DEPARTMENT1" display="no">.  Then the bind will work w/ this:

<cfajaxproxy bind="javascript:myHandler({UsersGrid.COMPANY},{UsersGrid.SECTORS1},{UsersGrid.DEPARTMENT1})"/>

<script type="text/javascript">

  function myHandler(COMPANY,SECTORS1,DEPARTMENT1) {

      //update the link's href

      document.getElementById('myLink').href = 'http://www.google.com/search?q=' + COMPANY;

      document.getElementById('Linkedin').href = 'http://www.google.com/search?q=linkedin' + COMPANY;

      //update SECTORS1's selected

      var theField = document.getElementById('SECTORS1');

      for(var i=0; i<theField.options.length; i++) {

          if(theField.options.value==SECTORS1) {

              theField.options.selected = true;

          } else {

              theField.options.selected = false;

          }

      }

     

      //update DEPARTMENT1's selected

      var theField = document.getElementById('DEPARTMENT1');

      for(var i=0; i<theField.options.length; i++) {

          if(theField.options.value==DEPARTMENT1) {

              theField.options.selected = true;

          } else {

              theField.options.selected = false;

          }

      }

  }

</script>

Basically, a bind needs matching values.  The grid's new DEPARTMENT1 column contains the numeric values that match up to the DEPARTMENT1 cfselect's values.  The reason the DEPARTMENTNOM grid column isn't a good candidate for the bind, is b/c it contains the string values of the department names.

Thanks,

-Aaron

Votes

Translate

Translate

Report

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
Jul 04, 2012 Jul 04, 2012

Copy link to clipboard

Copied

Thanks aaron!

Votes

Translate

Translate

Report

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
Engaged ,
Jul 04, 2012 Jul 04, 2012

Copy link to clipboard

Copied

LATEST

goodychurro1 wrote:

Thanks aaron!

You're welcome!

Votes

Translate

Translate

Report

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
Documentation