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

Bind ahref link (like cfinput) in cfform

Guest
May 11, 2012 May 11, 2012

Copy link to clipboard

Copied

Hi all

How can I output this value (that it correctly shown in a cfinput), also as a link? I am using cfform. As far as I can gather by googling I may have to use cfdiv or cflayout? Thank you

CFINPUT:

<cfinput type="text" name="COMPANY" label="Company" required="yes" width="200"
        bind="{UsersGrid.dataProvider[UsersGrid.selectedIndex]['COMPANY']}"
        onChange="UsersGrid.dataProvider.editField(UsersGrid.selectedIndex,

'COMPANY', COMPANY.text);">

MY ATTEMPT:

<a href="mysite.com?company=<cfoutput>#company#</cfoutput>">Company link</a>

Views

3.1K

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

Community Expert , May 14, 2012 May 14, 2012

goodychurro1 wrote:

<cfformitem>

Spot on! I have also been looking into <cfformitem type="html"> and <cfformitem type="script">

I came up with:

<cfformitem type="html" bind="<a href=""mysite.com?company={company.text}"">Company link</a>">

   </cfformitem>


Votes

Translate

Translate
Community Expert ,
May 12, 2012 May 12, 2012

Copy link to clipboard

Copied

Something like

<cfdiv id = "companyDiv" bind="<a href="""mysite.com?company=+{dt}+"">Company link</a>" />

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
May 12, 2012 May 12, 2012

Copy link to clipboard

Copied

Thanks for the reply BKBK I get this error:

Invalid token . found on line 129 at column 49. 
 
The CFML compiler was processing: 

The tag attribute mysite, on line 129, column 43. 
A cfdiv tag beginning on line 129, column 2.


The error occurred in member_welcome.cfm: line 129

127 :  128 : </cfformgroup>  129 : <cfdiv id = "companyDiv" bind="<a href="""mysite.com?company=+{dt}+"">Company link</a>" />  130 :  131 : <cfformgroup type="horizontal">  

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
Community Expert ,
May 12, 2012 May 12, 2012

Copy link to clipboard

Copied

My bad, I think. There should perhaps be 2 quotes after href=, not 3.

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
May 12, 2012 May 12, 2012

Copy link to clipboard

Copied

Thanks bkbk that sorted out that error but now I get a js alert error:

"Bind failed, element not found: dt"

I imagine this is because I have not selected a company yet so it has no data to bind, but that is the same case in the cfinputs and they don't thorw an error:

CFINPUT:

<cfinput type="text" name="COMPANY" label="Company" required="yes" width="200"
bind="{UsersGrid.dataProvider[UsersGrid.selectedIndex]['COMPANY']}"
onChange="UsersGrid.dataProvider.editField(UsersGrid.selectedIndex,

'COMPANY', COMPANY.text);">

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
Community Expert ,
May 12, 2012 May 12, 2012

Copy link to clipboard

Copied

goodychurro1 wrote:

Thanks bkbk that sorted out that error but now I get a js alert error:

"Bind failed, element not found: dt"

I imagine this is because I have not selected a company yet so it has no data to bind, but that is the same case in the cfinputs and they don't thorw an error:

You should have just filled in the field name in place of my 'dt'! Something like this

<cfdiv id = "companyDiv" bind="<a href=""mysite.com?company=+{company}+"">Company link</a>" />

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
May 12, 2012 May 12, 2012

Copy link to clipboard

Copied

Thanks bkbk, I tried that and get two errors:

1)Bind failed element not found: COMPANY

Bind failed element not found: companyDIV

Code:  <cfdiv id = "companyDiv" bind="<a href=""mysite.com?COMPANY=+{COMPANY}+"">Company link</a>" />

2) I also tried using the code in the cfinput to see if it would work but I get an error:

Error parsing bind expression at character 29:{ in Company link

Code:

<cfdiv id = "companyDiv" bind="<a href=""mysite.com?COMPANY=+{UsersGrid.dataProvider

[UsersGrid.selectedIndex]['COMPANY']}+"">Company link</a>" />

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
Community Expert ,
May 13, 2012 May 13, 2012

Copy link to clipboard

Copied

I have tested with:

<cfdiv id = "companyDiv" bind="<a href=""mysite.com?company=+{company}+"">Company link</a>" />

and it works! But then, just as you had guessed, the form field should already contain a value.

Try this. Preload the cfinput by adding the attribute bindOnLoad="true".

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
May 13, 2012 May 13, 2012

Copy link to clipboard

Copied

Thanks for the input BKBK I tried with three different lines but I still get COMPANY not defined, I am using the code within the cfformgroup tag:

1)

<cfdiv id = "companyDiv" bindOnLoad="true" bind="<a href=""mysite.com?company=+

{COMPANY}+"">Company link</a>" />

2)

<cfdiv id = "companyDiv" bindOnLoad="yes" bind="<a href=""mysite.com?company=+

{COMPANY}+"">Company link</a>" />

3)

<cfdiv id = "companyDiv" bindOnLoad="no" bind="<a href=""mysite.com?company=+

{COMPANY}+"">Company link</a>" />

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
Community Expert ,
May 13, 2012 May 13, 2012

Copy link to clipboard

Copied

The bindOnLoad suggestion is for <cfinput>, not for <cfdiv>. Please reread my post.

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
May 13, 2012 May 13, 2012

Copy link to clipboard

Copied

Cheers, OK I put the bindOnLoad on the cfinput COMPANY field:

<cfinput type="text" bindOnLoad="true" name="COMPANY" label="Company" required="yes" width="200"

bind="{UsersGrid.dataProvider[UsersGrid.selectedIndex]['COMPANY']}" onChange="UsersGrid.dataProvider.editField

(UsersGrid.selectedIndex, 'COMPANY', COMPANY.text);">

And this line also within the cfformgroup tag:

<cfdiv id = "companyDiv" bind="<a href=""mysite.com?company=+{COMPANY}+"">Company link</a>" />

I get these three errors:

bind failed element not found COMPANY

Element not found COMPANY

Element not found companyDiv

Message was edited as I changed the case of database fields

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
Community Expert ,
May 13, 2012 May 13, 2012

Copy link to clipboard

Copied

I overlooked the fact you might be using a Flash form. The cfdiv tag is HTML. It won't work with Flash. In any case, not as we want here. However, we're on the right track. Convince yourself that this works:

<cfform>

    <cfinput name="company" type="text" value="myCompany">

</cfform>

<cfdiv id = "companyDiv" bind="<a href=""mysite.com.cfm?company=+{company}+"">Company link</a>" />

The challenge is to find an equivalent solution for a Flash form (update: which I am looking into). Alternatively, you could also look into converting your form into HTML.

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
May 13, 2012 May 13, 2012

Copy link to clipboard

Copied

Hi BKBK

I changed the cfform format and the cfgrid format to html but that makes none of the binds work!

I tried this code below the form and it works showing mycompany as the parameter, but the point obviously is that it is not dynamic.

The link doesn't have to be within the form. Maybe there is a way to set a variable with the value from the cfinput? Or have we hit a flash induced brick wall? Cheers

<cfform>

    <cfinput name="company" type="text" value="myCompany">

</cfform>

<cfdiv id = "companyDiv" bind="<a href=""mysite.com.cfm?company=+{company}+"">Company link</a>" />

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
Community Expert ,
May 13, 2012 May 13, 2012

Copy link to clipboard

Copied

goodychurro1 wrote:

I changed the cfform format and the cfgrid format to html but that makes none of the binds work!

It's usually not sufficient to change the format from flash to html. You may have to change the code in the bind expression from actionscript to an html-compatible form.

I tried this code below the form and it works showing mycompany as the parameter, but the point obviously is that it is not dynamic.

<cfform>

    <cfinput name="company" type="text" value="myCompany">

</cfform>

<cfdiv id = "companyDiv" bind="<a href=""mysite.com.cfm?company=+{company}+"">Company link</a>" />

I didn't forget the requirement of passing the value dynamically via binding. This is just a proof of concept to show that there is a solution for HTML forms.

The link doesn't have to be within the form. Maybe there is a way to set a variable with the value from the cfinput? Or have we hit a flash induced brick wall?

Flash forms are trickier to manipulate in ColdFusion than HTML forms. However, there is always a way around most problems.

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
May 13, 2012 May 13, 2012

Copy link to clipboard

Copied

Searching around the internet I found this code which when put in the cfform shows a list of all the company names with a link. There is no bind but it is interesting as a starting point mixing html in a flash form.  What do you think?

<cfformgroup type="panel" label="Current forums" visible="Yes" enabled="Yes">

<cfformitem type="html" visible="Yes" enabled="Yes">

<cfloop query="qNames">

<cfoutput><a

href="threads.cfm?fid=#Company#">#Company#</a><br

/></cfoutput>

</cfloop>

</cfformitem>

</cfformgroup>

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
Community Expert ,
May 14, 2012 May 14, 2012

Copy link to clipboard

Copied

goodychurro1 wrote:

<cfformitem>

Spot on! I have also been looking into <cfformitem type="html"> and <cfformitem type="script">

I came up with:

<cfformitem type="html" bind="<a href=""mysite.com?company={company.text}"">Company link</a>">

   </cfformitem>


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
May 14, 2012 May 14, 2012

Copy link to clipboard

Copied

LATEST

Thank you BKBK that works great! I learnt a lot about flash forms, I think I will have to eventually change it to html and the cfgrid as well (it appears that it can be done for both) but that is for another opportunity!

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