Federal Projects:
<cfselect name="AdminID" bind="cfc:folder.components.forms.getProjects()" display="ProjectName" value="AdminID" bindonload="true" />
Administrators:
<cfselect name="AdminName" bind="cfc:folder.components.forms.getAdminInfo({AdminID})" display="FullName" value="PrincipalID" />

The Code above queries a cfc and returns the results to the second cfselect. My question would be how to return the result to a cfinput box? Is that even possible.

Recommended Answers

All 5 Replies

Here is an example of a cfinput bind...

<cfinput type="text" visible="no" width="0" label="Please select a forum topic" name="topic_id" bind="{data.selectedItem.topic_id}">

The code above binds to a grid called data and the selected record for column topic_id. It's only visible="no" because I use it as a hidden way to pass data to another page

Member Avatar for gklandes

If I understand you correctly, when the user selects a value in the 2nd select box, the selected value should show up in a text field. This can be done pretty quickly with your own javascripting - add an "onchange" event to the 2nd select...

<cfselect name="AdminName" bind="cfc:folder.components.forms.getAdminInfo({AdminID})" display="FullName" value="PrincipalID" 
onchange="document.getElementById('txt').value = this.options[this.selectedIndex].text;"
/>
<input name="txt" id="txt" />

note that this will populate the text field with the "Text" of the selected option - this is what is visible in the select area as opposed to the "value" of the option which is what is actually sent to the server when the form is submitted:

<option value="foo">Bar</option>

foo is the value above, while Bar is the text.

The Code above queries a cfc and returns the results to the second cfselect. My question would be how to return the result to a cfinput box? Is that even possible.

It doesn't make much sense to return _multiple_ results to a cfinput box. Perhaps you're thinking of something different, like an auto-suggest maybe..?

It doesn't make much sense to return _multiple_ results to a cfinput box. Perhaps you're thinking of something different, like an auto-suggest maybe..?

Yeah I had to end up using an auto-suggest.

Yeah, that makes more sense.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.