Solved

Form Auto-Population

Posted on 2004-10-15
9
368 Views
Last Modified: 2013-12-24
I have a form, that once the user chooses a name, I want it to automatically fill in information from the query onto the form.

<CFQUERY datasource="myds" name="employees" blockfactor="100">
      SELECT *
      FROM tbl_employees
      WHERE Active=1
      ORDER BY SortName asc      
</CFQUERY>

And the form just looks like this:

Name:  Drop Down box with names from the above employees query
Agt ID:  Blank Box (this is where I want the agt ID from the employees query to populate automatically when the user chooses a name from the above box.

Is there any way to do this?
0
Comment
Question by:Lee R Liddick Jr
  • 2
  • 2
  • 2
  • +2
9 Comments
 
LVL 21

Expert Comment

by:pinaldave
ID: 12322586
This is how you populate the values of the checkbox.

Empolyee account :<input type="text" name="activated_accounts1" value="#employees.activated_accounts#">

I will post hte code for this automatically populated by selecting drop down soon.
Regards,
---Pinal
0
 
LVL 21

Assisted Solution

by:pinaldave
pinaldave earned 50 total points
ID: 12322603
Okey this is what you will have to do is use javascript or submit button .
I will use javascript that submits to itself when someone selects the drop down and form post to itself and
that will run another query of
<CFQUERY datasource="myds" name="employees" blockfactor="100">
     SELECT *
     FROM tbl_employees
     WHERE Active=1
 and account_id = #form.account_id#
     ORDER BY SortName asc    
</CFQUERY>

adn then post the result in
<input type="text" name="activated_accounts1" value="#employees.activated_accounts#">
0
 
LVL 5

Assisted Solution

by:umbrae
umbrae earned 50 total points
ID: 12322808
Put this in the HEAD section of your page:
<script language="javascript">
var agents = new Array();
<cfoutput query="employees">
agents[#employees.currentRow#] = "#employees.agtID#";
</cfoutput>
</script>

then in your body code:

<select name="employeenames" onChange="document.getElementById('empagtID').value = agents[this.selectedIndex.value];">
<cfoutput query="employees">
<option value="#employees.currentRow#">#employees.name#</option>
</cfoutput>
</select>

<input type="text" name="empagtID" id="empagtID">


This may work. Code is untested, but I think something like that will get you the results you're looking for.

-Umbrae
0
Easy, flexible multimedia distribution & control

Coming soon!  Ideal for large-scale A/V applications, ATEN's VM3200 Modular Matrix Switch is an all-in-one solution that simplifies video wall integration. Easily customize display layouts to see what you want, how you want it in 4k.

 
LVL 7

Accepted Solution

by:
black0ps earned 50 total points
ID: 12322868
<cfquery name="Employees">
</cfquery>
<form name="Emp">
<select name="Employee" onChange="document.Emp.ID.value = this.options[this.options.selectedIndex].value;">
<cfoutput query="Employees"><option value="#Employees.AgentID#">#Employees.Name#</option>
</cfoutput>
</select>
<input type="text" name="ID" value="">
</form>
0
 
LVL 5

Expert Comment

by:kkhipple
ID: 12324170
try this piece of code....  

<javascript>

function entsub() {

function ConfirmSSN(sSSN)
{
  document.all.WorkFrame.src = "confirmSSN.cfm?SSN=" + sSSN;
}


function enterinfo()
  {
  document.employees.SSN.value = retssn;
  ConfirmSSN(retssn)
  }
</script>
<body bgcolor="silver">
<!--- Begin Form --->
<table style="border-width: thin; border-color: black; border-style:
solid;">
<tr>
<td>
<table cellspacing="2" cellpadding="2" border="0">
<form name="employees" action="index.cfm" method="post">
<tr>
<td colspan="2" class="text"><font style="font-size:
8pt;"><strong>Search Employees By Social Security
Number</strong></font></td>
</tr>
<tr>
    <td class="text">SSN:</td>
    <td><input type="text" name="SSN" class="field" size="10"
onkeyup="entsub();" ondblclick="ConfirmSSN(this.value);"> <a href="#"
onclick="showModalDialog('namepopup.cfm',window,'dialogHeight:276px;dial
ogWidth:261px');" name="button" id="button"><img src="popup.gif"
border="0"></a></td>
</tr>
<!---Hide rest of form until --->
<tr>
    <td class="text">Last Name:</td>
    <td><input READONLY type="text"  name="last" size="15"
class="nonfield"></td>
</tr>
<tr>
    <td class="text">First Name:</td>
    <td><input READONLY type="text"  name="first" size="15"
class="nonfield"></td>
</tr>
<!--- end div --->
</form>
</table>
</td>
</tr>
</table>
<!--- end form--->
<!--- create Workframe --->
<iframe id="WorkFrame" name="WorkFrame" height="0" width="0"></iframe>
0
 
LVL 5

Expert Comment

by:kkhipple
ID: 12324199
0
 

Author Comment

by:Lee R Liddick Jr
ID: 12328525
pindaldave, umbrae, and blackops...i've tried those suggestions and still can't get it to work.  The best I've gotten was the one from blackops, but it's giveing me a wrong value in the Agt ID box.  I will look at this again sometime soon, but going to just divide the points between you guys and try and figure it out later.  Thanks...
0
 
LVL 7

Expert Comment

by:black0ps
ID: 12329284
I think I can speak for umbrae and pindaldave, that it's not just about points. We want to help you get this deal working. Post the code that you are using and I'll give you some more advice on what to populate where.

-- Ian
0
 

Author Comment

by:Lee R Liddick Jr
ID: 12337889
Yes I know, just didn't want to keep this open until I got to it.  I just opened another question and it is posted at http://www.experts-exchange.com/Web/WebDevSoftware/ColdFusion/Q_21172334.html if you wanted to take a look at it.  Thanks guys...
0

Featured Post

Flexible connectivity for any environment

The KE6900 series can extend and deploy computers with high definition displays across multiple stations in a variety of applications that suit any environment. Expand computer use to stations across multiple rooms with dynamic access.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Internal DNS Zone Issue 13 80
Asp.net plan security, reliable, stable 2 126
Asp.net Hosting Plan security, reliable, stable 1 79
Help with a redirect in web.config file 8 56
Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question