Manager Name:

Basically, whichever employee is selected from the list, in the database, IsManager is changed from Yes to No. However, upon submission of the selection, i have the following javascript function: Which produces a little pop up asking the user if they are sure that they wish to demote that manager. My problem lies with this - I want to display a list of employees who will be affected by this demotion of the manager. I want to list it in the same pop up box as the other message, but im stuck on how to do it. I know that it will need a query to produce the list of employees that have a value in the ReportsTo field of the database which matches the value of the EmployeeID for the manager that has been selected using the drop down list. For example - Say tha John Smith has been selected using the drop down list. In the database, Bill Johnson, and possibly others will have a ReportsTo value equal to the employeeID of Bill Johnson, and hence, i want those names displayed in a list so that the user knows demoting that manager will have an effect on those employees. Ive written a query to retrieve the list of employees for the particular "ReportsTo" value and it looks like this: SELECT * FROM Employees WHERE ReportsTo = #EmployeeID# ORDER BY LastName, FirstName And it works fine. I just cant figure out how to get the results into the javascript, or where to put the query in the first place! It cant be placed above the HTML, as the EmployeeID is not defined prior to being selected in the select box. Any help would be excellent. Thanks guys, Matt [allowsmilie] => 1 [showsignature] => 0 [ipaddress] => [iconid] => 0 [visible] => 1 [attach] => 0 [infraction] => 0 [reportthreadid] => 0 [isusenetpost] => 1 [msgid] => [ref] => [htmlstate] => on_nl2br [postusername] => Matt McSpirit [ip] => webforumsuser@m [isdeleted] => 0 [usergroupid] => [membergroupids] => [displaygroupid] => [password] => [passworddate] => [email] => [styleid] => [parentemail] => [homepage] => [icq] => [aim] => [yahoo] => [msn] => [skype] => [showvbcode] => [showbirthday] => [usertitle] => [customtitle] => [joindate] => [daysprune] => [lastvisit] => [lastactivity] => [lastpost] => [lastpostid] => [posts] => [reputation] => [reputationlevelid] => [timezoneoffset] => [pmpopup] => [avatarid] => [avatarrevision] => [profilepicrevision] => [sigpicrevision] => [options] => [akvbghsfs_optionsfield] => [birthday] => [birthday_search] => [maxposts] => [startofweek] => [referrerid] => [languageid] => [emailstamp] => [threadedmode] => [autosubscribe] => [pmtotal] => [pmunread] => [salt] => [ipoints] => [infractions] => [warnings] => [infractiongroupids] => [infractiongroupid] => [adminoptions] => [profilevisits] => [friendcount] => [friendreqcount] => [vmunreadcount] => [vmmoderatedcount] => [socgroupinvitecount] => [socgroupreqcount] => [pcunreadcount] => [pcmoderatedcount] => [gmmoderatedcount] => [assetposthash] => [fbuserid] => [fbjoindate] => [fbname] => [logintype] => [fbaccesstoken] => [newrepcount] => [vbseo_likes_in] => [vbseo_likes_out] => [vbseo_likes_unread] => [temp] => [field1] => [field2] => [field3] => [field4] => [field5] => [subfolders] => [pmfolders] => [buddylist] => [ignorelist] => [signature] => [searchprefs] => [rank] => [icontitle] => [iconpath] => [avatarpath] => [hascustomavatar] => 0 [avatardateline] => [avwidth] => [avheight] => [edit_userid] => [edit_username] => [edit_dateline] => [edit_reason] => [hashistory] => [pagetext_html] => [hasimages] => [signatureparsed] => [sighasimages] => [sigpic] => [sigpicdateline] => [sigpicwidth] => [sigpicheight] => [postcount] => 1 [islastshown] => [isfirstshown] => 1 [attachments] => [allattachments] => ) --> Javascript and CFquery problem - Macromedia ColdFusion

Javascript and CFquery problem - Macromedia ColdFusion

Hi guys, im hoping you can help. Im currently working on a page that contains a single drop down list that is dynamically populated from the database. The list contains all the names of the managers in my application. The query that generates this list is as follows: <cfquery datasource="Project" name="Manager"> SELECT ReportsTo, EmployeeID, LastName & ', ' & FirstName As ManagerName FROM Employees WHERE IsManager = Yes ORDER BY LastName, FirstName </cfquery> And that list is displayed in the following form: <form action="managerProcessing.cfm?action=no" method="post" name="demoteManager" onsubmit="return demote()"> <table width="445px" cellspacing="5"> <tr> <td class="p" colspan="3">Select the manager you wish to ...

  1. #1

    Default Javascript and CFquery problem

    Hi guys, im hoping you can help.

    Im currently working on a page that contains a single drop down list that is
    dynamically populated from the database. The list contains all the names of
    the managers in my application. The query that generates this list is as
    follows:

    <cfquery datasource="Project" name="Manager">
    SELECT ReportsTo, EmployeeID, LastName & ', ' & FirstName As ManagerName
    FROM Employees
    WHERE IsManager = Yes
    ORDER BY LastName, FirstName
    </cfquery>

    And that list is displayed in the following form:

    <form action="managerProcessing.cfm?action=no" method="post"
    name="demoteManager" onsubmit="return demote()">

    <table width="445px" cellspacing="5">
    <tr>
    <td class="p" colspan="3">Select the manager you wish to demote from the drop
    down list and click 'Demote'.</td>
    </tr>

    <tr><td></td></tr>

    <!--- Select Menu to choose which Manager. It is dynamically populated from
    the database --->

    <tr>
    <td width="25%"><h3>Manager Name:</h3></td>
    <td><select name="EmployeeID" size="1">
    <cfoutput query="Manager">
    <option value="#EmployeeID#">#ManagerName#</option>
    </cfoutput>
    </select>
    <input type="submit" value="Demote" />
    </td>
    </tr>
    </table>
    </form>

    Basically, whichever employee is selected from the list, in the database,
    IsManager is changed from Yes to No. However, upon submission of the
    selection, i have the following javascript function:

    <script language="JavaScript" type="text/javascript">
    <!--
    function demote() {
    var managerList = doent.demoteManager.EmployeeID;
    var manager = managerList.options[managerList.selectedIndex].text;
    return confirm('Are you sure you want to demote ' + manager + ' from
    the position of manager?');
    }

    </script>

    Which produces a little pop up asking the user if they are sure that they wish
    to demote that manager.

    My problem lies with this - I want to display a list of employees who will be
    affected by this demotion of the manager. I want to list it in the same pop up
    box as the other message, but im stuck on how to do it. I know that it will
    need a query to produce the list of employees that have a value in the
    ReportsTo field of the database which matches the value of the EmployeeID for
    the manager that has been selected using the drop down list.

    For example - Say tha John Smith has been selected using the drop down list.
    In the database, Bill Johnson, and possibly others will have a ReportsTo value
    equal to the employeeID of Bill Johnson, and hence, i want those names
    displayed in a list so that the user knows demoting that manager will have an
    effect on those employees.

    Ive written a query to retrieve the list of employees for the particular
    "ReportsTo" value and it looks like this:

    <cfquery datasource="Project" name="EmployeeList">
    SELECT *
    FROM Employees
    WHERE ReportsTo = #EmployeeID#
    ORDER BY LastName, FirstName
    </cfquery>

    And it works fine.

    I just cant figure out how to get the results into the javascript, or where to
    put the query in the first place! It cant be placed above the HTML, as the
    EmployeeID is not defined prior to being selected in the select box.

    Any help would be excellent.

    Thanks guys,

    Matt

    Matt McSpirit Guest

  2. #2

    Default Re: Javascript and CFquery problem

    Well you really are talking about running a query based on the results of what
    a user selects in the first list. So you either have to refresh the page, so
    that you can pass the selected EmployeeID in, or pre-query all all possible
    managers and put them into JS arrays or something (which gets hairy). You
    cannot run a new CF query from a form select without submitting the page.
    (short of using Flash remoting or soemthing like that).

    Bryan


    blewis Guest

Similar Threads

  1. CFQUERY problem
    By moonroach1 in forum Coldfusion Database Access
    Replies: 4
    Last Post: August 3rd, 05:46 PM
  2. unusual cfquery problem
    By feral99 in forum Coldfusion - Advanced Techniques
    Replies: 0
    Last Post: May 9th, 12:13 AM
  3. double single quote problem in cfquery
    By Bigio in forum Coldfusion Database Access
    Replies: 7
    Last Post: April 25th, 09:46 PM
  4. <cfquery> syntax problem
    By samb1 in forum Macromedia ColdFusion
    Replies: 1
    Last Post: April 7th, 08:33 PM
  5. javascript problem
    By Dwayne Epps in forum Macromedia Dreamweaver
    Replies: 6
    Last Post: July 18th, 06:29 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139