Skip navigation
Currently Being Moderated

Bind ahref link (like cfinput) in cfform

May 11, 2012 10:16 PM

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>

 
Replies
  • Currently Being Moderated
    May 12, 2012 4:03 AM   in reply to goodychurro1

    Something like

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

     
    |
    Mark as:
  • Currently Being Moderated
    May 12, 2012 9:59 AM   in reply to goodychurro1

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

     
    |
    Mark as:
  • Currently Being Moderated
    May 12, 2012 10:32 AM   in reply to goodychurro1

    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>" />

     
    |
    Mark as:
  • Currently Being Moderated
    May 13, 2012 3:14 AM   in reply to goodychurro1

    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".

     
    |
    Mark as:
  • Currently Being Moderated
    May 13, 2012 8:21 AM   in reply to goodychurro1

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

     
    |
    Mark as:
  • Currently Being Moderated
    May 13, 2012 11:40 AM   in reply to goodychurro1

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    May 13, 2012 1:38 PM   in reply to goodychurro1

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    May 14, 2012 2:46 AM   in reply to goodychurro1

    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>

     


     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points