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" "">
<html xmlns="">
<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
<script type="text/javascript">
function goThere () {
<cfset lpage=1>
<div id="firstTable">
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse:collapse; border-color:#0000FF;" align="center">
<th>Job Code</th><th>Description</th>
<!--- Here's all members output nicely into a table --->
<td><a href="#cgi.SCRIPT_NAME#?code=#jobcode#" onclick="goThere ();">#description#</a></td>
<cfset lpage=2>
<cfif isDefined("url.code") and url.code is not "">
<cfquery name="getJobName" datasource="cfelSunrise" dbtype="ODBC">
select l.locationID as LID, 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
<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">
<th>First Name</th><th>Last Name</th><th>Community</th><th>State</th>
	<cfset totemps = 0>
<cfoutput query="getJobName">
<cfset totemps = totemps + 1>
<cfoutput><B>Total Number of Team Members : #totemps#</B></cfoutput>

Open in new window

Avatar of 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


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 () {

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

To be able to use the link you need to login.
try this u/n:SRZ35465
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
Avatar of Zvonko
Flag of North Macedonia image

Link to home
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?