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

Populating Text Fields in the form based on the Drop down

New Here ,
Dec 17, 2008 Dec 17, 2008
..
747
Translate
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
LEGEND ,
Dec 17, 2008 Dec 17, 2008
which version of CF are you using?
CF8 has many new ajax-based features built-in you could use for this.
data bindings is an obvious choice here - how good are you with CFCs?

which db are you using?
how are the tables the hold data for the drop-down and the text fields
related to each other?

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
Translate
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
New Here ,
Dec 17, 2008 Dec 17, 2008
Hi Azadi ,

Thanks for replying.
Iam working with Colfusion 8 , Dreamweaver CS3, Sql Server 2008. And all the data for the drop down and text boxes come from the same table.

Iam pretty much new to Coldfusion. Infact this is my first usage.But I guess Iam not that bad with CFC.
Please do hel me out.

Thanks.
Translate
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
New Here ,
Dec 18, 2008 Dec 18, 2008
Hi,
Please try the following
On Select of the dropdown submit it to same page or the page where you can query to the table.query it with respect to the dropdown variable.display the query variable.

Cheers
Moumita
Translate
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
New Here ,
Dec 18, 2008 Dec 18, 2008
Hey Moumita,

Thanks for your reply.
I tried the way you said earlier , but even then I couldn't get what Iam looking for. I submitted the form to the action page and refered the variable , but was not able to populate the text fields ( though was able to populate the drop down) .

Thanks
Translate
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
LEGEND ,
Dec 18, 2008 Dec 18, 2008
avanin16 wrote:
> Hey Moumita,
>
> Thanks for your reply.
> I tried the way you said earlier , but even then I couldn't get what Iam
> looking for. I submitted the form to the action page and refered the variable ,
> but was not able to populate the text fields ( though was able to populate the
> drop down) .
>
> Thanks
>
>

Providing a relevant piece of code or two so we can see what you are
actually doing or not doing may help.
Translate
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
New Here ,
Dec 19, 2008 Dec 19, 2008
Hi Ian,

Iam trying to create a form ( also has an action page) that can update the database with the new info added by the user.

To populate the drop down Iam using the following :

<cfquery name="q_update" datasource="Employee">
Select emp_dep from emp_data

</cfquery>
<table>
<tr>

<cfform action="Update_Action.cfm" method="Post" >
<select name="Emp_Dept" required="yes">
<option>Select Employee Department</option>
<cfoutput query ="q_update">
<option value= "#q_update.Emp_Dept#" >#Emp_Dept#</option>
</cfoutput> </select></tr>

------------------------- And I have 3 text fields , which I want to automatically populate by selecting the Employee Dept from the drop down -------------------------

<tr>
<td>Name:</td>
<td><input type="text" name="" value=""></td>
</tr>
<tr>
<td>Salary:</td>
<td><input type="text" name="" value=""></td>
</tr>
<tr>
<td>Emp ID:</td>
<td><input type="text" name="" value=""></td>
</tr>
<tr>
<td> </td>
<td><input type="Submit" value="Update Information"></td>
</tr>
</table></cfform>

Excuse me if there's any mistake.
Please do help me out.

Thanks in advance.
Translate
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
LEGEND ,
Dec 19, 2008 Dec 19, 2008
LATEST
avanin16 wrote:
>
> ------------------------- And I have 3 text fields , which I want to
> automatically populate by selecting the Employee Dept from the drop down
> -------------------------
>

If I understand correctly, you want data to populate the text fields
based when an option is selected in the select control. If so, first of
all, this is a client user interface requirement and not really a server
issue, even though the server *may* get involved in more sophisticated
solutions.

As a client problem, this is closely related to "two related selects".
A very common pattern where the values of one select control is based on
the chosen value in another select control. This patern is very common
and there are many, well documented examples available for a bit of
searching. You will need to modify the provided JavaScript code to
populate text fields rather then another select field, but that should
be fairly trivial.

Now the real challenge of all of this is where to get the data to
populate the desired form controls. By the time client code is running,
the server has completed all its work for this client, moved on to its
next job and completely forgotten about this request. One can provide
*all* the possible data for the dynamically populated fields in the
response to the request. This is fine for smaller data sets, but
becomes unwieldy as the amount of possible data grows.

Alternately one can make a new request to the server for the required
data after the choice has been made by the user in the select control.
If this is done as regular request, it will cause the page to be
refreshed with the new fields completed. Simple and straight forward
but this does lead to a rather clunky, blinking user experience.

With more effort it is possible to make this second response behind the
scenes using asynchronous JavaScript, commonly known as AJAX. The
latest version of ColdFusion contains several new functions to aid one
in the building of AJAX functionality.
Translate
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