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
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
...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
Copy link to clipboard
Copied
Thanks aaron!
Copy link to clipboard
Copied
goodychurro1 wrote:
Thanks aaron!
You're welcome!