Link to home
Create AccountLog in
Avatar of erikTsomik
erikTsomikFlag for United States of America

asked on

Switch pages on the self form posting coldfusion

I have a problem here . I have 2 tables. when i click on the link i want to dispaly table 2 but not the table 1. How can i do that with the self posting forms.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
 
 
<cfquery name="getJobCode" datasource="cfelSunrise" dbtype="ODBC">
SELECT DISTINCT JobCode_List.JobCode, JobCode_List.Description
FROM         EmployeeJobHistory INNER JOIN
                      JobCode_List ON EmployeeJobHistory.JobCode = JobCode_List.JobCode INNER JOIN
                      JobAssignment ON EmployeeJobHistory.Sequence = JobAssignment.Sequence INNER JOIN
                      Location ON JobAssignment.LocationID = Location.LocationID INNER JOIN
                      Employee ON EmployeeJobHistory.EmployeeID = Employee.EmployeeID
WHERE     (EmployeeJobHistory.EmployeeID > 0) AND (JobAssignment.EmplRcd = 0) AND (JobAssignment.EndDate IS NULL)
ORDER BY JobCode_List.Description
</cfquery>
<script type="text/javascript">
 
function goThere () {
//document.getElementById('firstTable').style.display='none';
document.getElementById('secondTable').style.display='block';
}
</script>
</script>
</head>
 
<body>
<cfset lpage=1>
<div id="firstTable">
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse:collapse; border-color:#0000FF;" align="center">
<tr>
<th>Job Code</th><th>Description</th>
</tr>
 
<!--- Here's all members output nicely into a table --->
 
<CFOUTPUT QUERY="getJobCode">
<tr>
<td>#jobcode#</td>
<td><a href="#cgi.SCRIPT_NAME#?code=#jobcode#" onclick="goThere ();">#description#</a></td>
</tr>
</CFOUTPUT>
 
</table>
</div>
<cfset lpage=2>
<cfif isDefined("url.code") and url.code is not "">
 
<cfquery name="getJobName" datasource="cfelSunrise" dbtype="ODBC">
select l.locationID as LID, l.name as LocName, l.State as lstate, 
			e.employeeID as EID, e.last_name as lname, e.first_name as fname, e.Middle_name as Mname, e.terminationdate,
			j.jobcode as jcode, j.description as jtitle,
			a.locationID, h.sequence, a.sequence, h.employeeID, h.jobCode, a.conciergeFlag, a.StartDate as hiredate, a.PsoftXferDate as xferdate
		from JobCode_List j
		join EmployeeJobHistory h			on h.JobCode = j.JobCode
		Inner Join JobAssignment a			on (h.sequence = a.sequence and a.enddate is NULL)
		Inner join Location l				ON l.LocationID = a.LocationID
		Inner join Employee e				on e.EmployeeID = h.EmployeeID
		where j.JobCode = '#url.Code#'
		order by e.last_name, e.first_name, e.middle_name
 
</cfquery>
<form action="list_jobCode.cfm" method="post">
<div id="secondTable">
<table border="1" style="border-collapse:collapse; border-color:#0000CC;" cellspacing="1" cellpadding="3" align="center">
<tr>
<th>First Name</th><th>Last Name</th><th>Community</th><th>State</th>
</tr>
	<cfset totemps = 0>
<cfoutput query="getJobName">
<tr>
<cfset totemps = totemps + 1>
<td>#fname#</td><td>#lname#</td><td>#locname#</td><td>#lstate#</td>
 
 
</tr>
 
 
</cfoutput>
</table>
</cfif>
<cfoutput><B>Total Number of Team Members : #totemps#</B></cfoutput>
</div>
</form>
 </body>
</html>

Open in new window

Avatar of Zvonko
Zvonko
Flag of North Macedonia image

Add ";return false" to the onClick event handler of your link.
Like this:
<a href="#cgi.SCRIPT_NAME#?code=#jobcode#" onclick="goThere();return false">#description#</a>

Open in new window

Avatar of erikTsomik

ASKER

that works but the problem that I am having now when I go back to the first Table it keeod th url
it is partially work but the first time I click on the link it gets redirected back to the first table then I click the second time it start displaying the second table . What is wrong ? Why I have to do it twise?
Change your JavaScript function to this:
<script type="text/javascript">
function goThere () {
  document.getElementById('firstTable').style.display='none';
  document.getElementById('secondTable').style.display='block';
}
</script>

Open in new window

Actually i did that already but it does not seems to be that url get defined when i first time click on the link
"I have 2 tables. when i click on the link i want to dispaly table 2 but not the table 1."

That is what the script is doing.

So please start from scratch to explain what your problem is.
If you changed the onclick like I proposed then the link does no go nowhere. The link ONLY calls the JavaScript function.

So please state what you do and what you get and what you expect. (it does not work is no info for me)
OK . What i need is . On the first page display the table with the clickable links. So when the link get clicked I want to dispaly the socond table with result based on the url variable that i passing while pressing the link .

SO you can actually see this on this page
http://testing.omnilearn.com/sunriseportal/TTI/list_jobcode.cfm

To be able to use the link you need to login.
try this u/n:SRZ35465
p/w:test
It does not work.
Anyway, explain as I asked above what you do, what you get and what is the difference to that you expected.

well when i clicked on the link I should see the result based on url. What do get I get redirected back and then i cliked second time then it working
I do not understand your question. Please try to explain it in English.
well when i clicked on the link I should see the result based on url variable that being posted(url.code). What I get is  I get redirected back and when  i clik second time on the link then it working. So I assuming that url variable does not get defined when i click first time

 
I can help you when you explain to me what you want to do.
Either is my English so bad that I do not understand you or you do not concentrate to ONLY answer to me ONLY what you want me to show to you.
So again please and stay calm: what should I show to you?


try going through the code that posted then it becomes clearer
ASKER CERTIFIED SOLUTION
Avatar of Zvonko
Zvonko
Flag of North Macedonia image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Do you need more support on this?
Yes I still need help. I still need to click twice on the link in order ot get to the second table
So let us go again step by step.
What is your link code that you use actualy?
<td><a href="#cgi.SCRIPT_NAME#?code=#jobcode#" onclick="goThere ();return false;">#description#</a></td>
OK, the href of that link is ignored. So only action is executed from script goThere(). Show please the goThere() function.
Can we see the page online in action?