Skip to main content
Inspiring
October 28, 2009
Answered

Cfselect populating cfinput readonly?

  • October 28, 2009
  • 2 replies
  • 2920 views

Good morning all,

I have a form that I want to use cfselect to drop employee FN and LN from the drop down username into a readonly cfinput. Do I need to bind or what is the best method to accomplish this? I also want to open a new form (popup) to select from there to other fields in the original form. I know the second part is javascript but can anybody point me in the right direction?

Thanks in advance,

djkhalif

This topic has been closed for replies.
Correct answer BKBK

You may use bind in both cases. Here's an example to start you up

<div>
<strong>Form 1</strong>
<cfform id="form1" name="form1">
<select name="firstName">
<option value="">Select first name</option>
<option value="01">Alf</option>
<option value="02">Bill</option>
</select>
<br>
First Name: <cfinput type="text" name="fn" bind="{firstName.text}" readonly="true">
<br>
City: <cfinput type="text" name="city1" bind="{form2:city2}">
<br>
Country: <cfinput type="text" name="country1" bind="{form2:country2}">
</cfform>
</div>

<div>
<strong>Form 2</strong>
<cfform id="form2" name="form2">
<select name="city2">
<option value="">Select city</option>
<option value="Amsterdam">Amsterdam</option>
<option value="Bratislava">Bratislava</option>
</select>
<br>
Country: <cfinput type="text" name="country2">
</cfform>
</div>

2 replies

BKBK
Community Expert
BKBKCommunity ExpertCorrect answer
Community Expert
October 29, 2009

You may use bind in both cases. Here's an example to start you up

<div>
<strong>Form 1</strong>
<cfform id="form1" name="form1">
<select name="firstName">
<option value="">Select first name</option>
<option value="01">Alf</option>
<option value="02">Bill</option>
</select>
<br>
First Name: <cfinput type="text" name="fn" bind="{firstName.text}" readonly="true">
<br>
City: <cfinput type="text" name="city1" bind="{form2:city2}">
<br>
Country: <cfinput type="text" name="country1" bind="{form2:country2}">
</cfform>
</div>

<div>
<strong>Form 2</strong>
<cfform id="form2" name="form2">
<select name="city2">
<option value="">Select city</option>
<option value="Amsterdam">Amsterdam</option>
<option value="Bratislava">Bratislava</option>
</select>
<br>
Country: <cfinput type="text" name="country2">
</cfform>
</div>

djkhalifAuthor
Inspiring
October 29, 2009

BKBK,

That did it!

Thanks,

djkhalif

djkhalifAuthor
Inspiring
October 29, 2009

BKBK,

I do see that in a form the format="flash" does not work bind. Nor can I use values from two columns with <cfselect query="tlkp_Inspector" value="firstName"></cfselect>. For value, value="firstName lastName"

Inspiring
October 28, 2009

<input> has a disabled attribute to make it read only.  To change the value based on another form field, you'll have to use javascript.