Solved

F/U to Qn /ColdFusion/#Q_21170271.html - pindaldave, umbrae, and blackops

Posted on 2004-10-18
7
269 Views
Last Modified: 2013-12-24
This is a follow-up to question http://www.experts-exchange.com/Web/WebDevSoftware/ColdFusion/Q_21170271.html#12329284 .  

This is the form code with the query section.  When the user chooses the employee, I want the input "extension" to be automatically completed by taking that data from the query.

dbase field names in tbl_employees that are used: EmployeeID & SortName & Extension

<!-- BEGIN QUERY SECTION -->
<CFQUERY name="employees" datasource="mydns">
SELECT *
FROM tbl_employees
WHERE Active=1
ORDER BY SortName asc
</CFQUERY>
<!-- END QUERY SECTION -->

<!-- BEGIN Agent Trace Request Form -->
<CFFORM NAME="agttrace" ACTION="agt_trace-post.cfm" METHOD="POST">      
<table bgcolor="336699" width="95%" cellspacing="2" cellpadding="2" border="0">
<tr>
<td class="smallsilver" align="right" valign="middle">
Employee:<span class="smallred">*</span>
</td>
<td>
<SELECT name="EmployeeID">
<OPTION value="">
<CFOUTPUT query="Employees">
<OPTION value="#employeeid#">#SortName#
</CFOUTPUT>
</SELECT>
</td>
</tr>
<tr>
<td class="smallsilver" align="right" valign="middle">
CMS Agent ID:<span class="smallred">*</span>
</td>
<td>
<input type="text" name="extension" value="">
</td>
</tr>
<tr>
<td class="smallsilver" align="right" valign="middle">
Continuous Record:
</td>
<td class="small">
<input type="Radio" name="ContRec" value="Yes">Yes<BR>
<input type="Radio" name="ContRec" value="No" checked>No
</td>
</tr>
<tr>
<td class="tinysilver" align="left" valign="middle" colspan="2">
<font color="Red">*</font> = Required fields
</td>
</tr>
<tr>
<td align="center" valign="middle" colspan="2">
<input type="hidden" name="SubmitTime" value="<cfoutput>#CreateODBCDateTime(DateAdd("h",3, Now()))#</cfoutput>">
<input type="hidden" name="SubmittedBy" value="<cfoutput>#UserInitials#</cfoutput>">                                                
<INPUT type="Submit" value="Submit" class="smallblue">
<img src="../images/dot_clear.gif" height="2" width="15">                                          
<INPUT type="Reset" value="Clear Form" class="smallblue">
</td>
</tr>
</table>
</CFFORM>
<!-- END Agent Trace Request Form -->                  
0
Comment
Question by:Lee R Liddick Jr
7 Comments
 
LVL 5

Expert Comment

by:umbrae
Comment Utility
As black0ps' previous code suggested, something like this may be correct:

<td>
<SELECT name="EmployeeID" onChange="document.agttrace.extension.value = this.options[this.selectedIndex].value">
<OPTION value="">
<CFOUTPUT query="Employees">
<OPTION value="#employeeid#">#SortName#
</CFOUTPUT>
</SELECT>
</td>
0
 
LVL 5

Accepted Solution

by:
umbrae earned 150 total points
Comment Utility
Whoops, thats incorrect.

Try this:

<td>
<SELECT name="EmployeeID" onChange="document.agttrace.extension.value = this.options[this.selectedIndex].value">
<OPTION value="">
<CFOUTPUT query="Employees">
<OPTION value="#extension#">#SortName#
</CFOUTPUT>
</SELECT>
</td>


The option value should be extension, not employeeID.

-Umbrae
0
 
LVL 7

Expert Comment

by:black0ps
Comment Utility
Your code looks fine. Add the following to the opening of your select tag:

 onChange="document.agttrace.extension.value = this.options[this.options.selectedIndex].value;"
0
Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

 
LVL 5

Expert Comment

by:umbrae
Comment Utility
black0ps, is it this.selectedIndex or this.options.selectedIndex?

Honestly not sure.
0
 

Author Comment

by:Lee R Liddick Jr
Comment Utility
Okay...I used the code that umbrae posted and it functions properly.  When I choose a name, the extension field is populated with the corresponding number to that agent.  Looks good.  Thank you!
0
 
LVL 7

Expert Comment

by:black0ps
Comment Utility
umbrae, I think it's either one. I didn't check my code with your when I posted. I just copied and pasted without really looking.

-- Ian
0
 
LVL 21

Expert Comment

by:pinaldave
Comment Utility
good to know it worked. I was out visiting my friends in LA and could not participate here.
Have a good day!
---Pinal
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
The purpose of this video is to demonstrate how to create a Printer Friendly PDF on a WordPress Page. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome Screenshot” Google Chrome Extension, and SmallPDF.com Log…
The purpose of this video is to demonstrate how to set up the permalinks on a WordPress Website. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Go t…

762 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now