Hi,
Below is the detailed explanation of my problem
My application has two different users...
a) students
b) advisors.
When the advisor logs in, he has two links to navigate to
The first page has drop down menus of other advisors from
which he can add permissions for some activities. In the second
page, the advisor has a form with text fields where he has to enter
the student details manually. Right now there is a <a
href="index.cfm">Add student only for me</a>. That is when
the advisors click the "add student only for me" , adds a new
student, and i am retrieving the values and making them display in
the page.
I am doing this as follows:
a) I am retreiving the student name as a link, so when the
advisor wants to edit some information about the student , he can
do so.
b) Initially, I am setting two values like
<cfset student_edit = 0>
<cfset student_add = 0>
so when the student name is clicked , i set the student_edit
to 1, and have the following hidden values:
<cfif student_edit eq 1>
<input type = "hidden name="editaction" value="edit">
<cfelse>
<input type="hidden" name="addaction" value="add">
then i am creating my component object (by using <cfset
saveobject = createObject(component.addstudent)>)and pass the
required parameters like firstname, etc for saving the student
details. There is a function called save_student() which requires
parameters.
All this is working fine.
Recently, my prof asked me to add another link which says
"Add student for all advisors". That is, the advisors he added in
the previous page should also see these students in their students
page. Currently What I am doing is as follow:
a) I created another anchor link saying "Add students for all
advisors". I wrote a query to get the advisors whom the current
advisor gave permissions to. Then I am getting their IDs from the
database, and when I click the button, this particular student will
get inserted for every advisor. So I write another function in the
component to accomodate this change, which inserts this particular
student for all the advisors. I am calling this function using the
same component object I created above. Previously, because I coded
that if its not an edit action, then add the student. Like below:
<a href="index.cfm" onClick="addform(1);return false;"
<cfif editaction EQ 1>Save<cfelse>Add New
Student.</cfif></a>. the addform() function is for
validation purposes
I did not want to change the above code. So I wrote a
javascript function like "addstudentforall()" in which I called the
"add student to all advisors" function i wrote in the component,
and used onclick to call the javascript function.
<a href="index.cfm"
onClick="addstudentsforall();addform(1);return false;" <cfif
editaction EQ 1>Save<cfelse>Add New Student for
all.</cfif></a>.
Now, the problem I am facing.
When I do this separately, it works for individual links, but
when I place the existing "add student for me" function above the
new javascript function, both the links are showing the same
functionailty that is both the links add the student only for the
current advisor, and if I place the javascript function above the
existing code, both the links add students for all the advisors. I
have been going crazy on how to approach this. It would be great if
you provide any suggestions and tell me if my approach is right.
I hope you understood my question.
Thanks