URL Method for 3 tables? | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| |
Hey Everyone,
i been working on trying to understand the URL method of retrieving information for the last week, but i am stuck. I been able to get one table of information, but now i need to get 3 tables of information at the same time an i am running into trouble. Each table has a number in common with the other, each has a field that holds the number (but fields have different name). For example ticketMaster table has the field pk_ticketID which holds the number 1, serial has the field pkb_fk_ticketNo which holds the number 1, and parts has the field fk_ticketNo which holds the number 1. Right now i can get the correct table information for ticketMaster but for the serial an parts i get all the records that are in those tables instead of just the one record needed, which in this case is the one record that holds the number 1.
Right now here is what i have -
<!---Shows what was previously entered into table ticketmaster--->
-
<cfquery name="ticket" datasource="CustomerSupport">
-
SELECT pk_ticketID,title,priority,status,
-
cost_center,fk_customer_number,
-
customer_company,customer_Fname,customer_Lname,
-
customer_add1,customer_city,customer_state,
-
customer_zip,customer_email,customer_pri_phone,
-
customer_sec_phone,customer_notes,htpp FROM dbo.tbl_CS_ticketMaster
-
WHERE pk_ticketID = #URL.pk_ticketID#
-
</cfquery>
-
-
<cfquery name="serial" datasource="CustomerSupport">
-
SELECT pka_serialNo,pkb_fk_ticketNo,model_no,product_type ,
-
software_hardware,resolution,resolution_date,
-
verification_date,rma_data,
-
type_hardware_failure,dept_responsibility,resoluti on_verified_by FROM dbo.tbl_CS_serial
-
</cfquery>
-
-
<cfquery name="parts" datasource="CustomerSupport">
-
SELECT pk_partID,fk_serialNo,fk_ticketNo,hc_partNo,
-
part_returned,defective,submission
-
FROM dbo.tbl_CS_parts
-
</cfquery>
-
-
<form name="page1" id="page1" action="saveticket1edit.cfm?<cfoutput query="ticket">pk_ticketID=#pk_ticketID#</cfoutput><cfoutput query="serial">&pkb_fk_ticketNo=#pkb_fk_ticketNo#</cfoutput><cfoutput query="parts">&fk_ticketNo=#fk_ticketNo#</cfoutput>"
-
method="POST" onSubmit="return validate_form();">
-
</form>
if anyone could explain to me how to get the url method to work with 3 fields in 3 different tables i would really appreciate it.
Thank you in advance,
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: URL Method for 3 tables?
You could combine all three into one query and perform a join operation. The best way would depend on the database and the dialect of SQL used, but a very simple way would be something like: - select ...
-
from ticket, serial, parts
-
where serial.fk_id = ticket.id and parts.fk_id = ticket.id
-
and ticket.id = #url...#
You match the foreign keys with the primary key of the main table to avoid duplicates.
| | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: URL Method for 3 tables? Quote:
Originally Posted by acoder You could combine all three into one query and perform a join operation. The best way would depend on the database and the dialect of SQL used, but a very simple way would be something like: - select ...
-
from ticket, serial, parts
-
where serial.fk_id = ticket.id and parts.fk_id = ticket.id
-
and ticket.id = #url...#
You match the foreign keys with the primary key of the main table to avoid duplicates. Hey Acoder,
Well here is what i have, but its still not getting the right information, it still getting all the rows in the tables for serial and parts - <!---Shows what was previously entered into table ticketmaster--->
-
<cfquery name="ticket" datasource="CustomerSupport">
-
SELECT pk_ticketID,title,priority,status,cost_center,fk_customer_number,
-
customer_company,customer_Fname,customer_Lname,customer_add1
-
,customer_city,customer_state,
-
customer_zip,customer_email,customer_pri_phone,
-
customer_sec_phone,customer_notes,htpp FROM dbo.tbl_CS_ticketMaster
-
WHERE pk_ticketID = #URL.pk_ticketID#
-
</cfquery>
-
-
<cfquery name="serial" datasource="CustomerSupport">
-
SELECT pka_serialNo,pkb_fk_ticketNo,model_no,product_type,software_hardware,
-
resolution,resolution_date,
-
verification_date,rma_data,type_hardware_failure,dept_responsibility,
-
resolution_verified_by FROM dbo.tbl_CS_serial
-
-
</cfquery>
-
-
<cfquery name="parts" datasource="CustomerSupport">
-
SELECT pk_partID,fk_serialNo,fk_ticketNo,hc_partNo,part_returned,defective,submission
-
FROM dbo.tbl_CS_parts
-
</cfquery>
-
-
-
<cfquery name="all" datasource="CustomerSupport">
-
SELECT *
-
FROM dbo.tbl_CS_ticketMaster,dbo.tbl_CS_serial,dbo.tbl_CS_parts
-
WHERE pkb_fk_ticketNo = pk_ticketID and pk_partID = pk_ticketID
-
and pk_ticketID = #URL.pk_ticketID#
-
</cfquery>
-
-
<cfoutput query="all">
-
<form name="page1" id="page1" action="saveticket1edit.cfm?pk_ticketID=#pk_ticketID#"
-
method="POST" onSubmit="return validate_form();">
-
</cfoutput>
-
</form>
-
-
-
Thank you,
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: URL Method for 3 tables?
What's the relationship between serial/parts and ticket. Is it many-to-one, i.e. many serials and parts to one ticket?
| | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: URL Method for 3 tables? Quote:
Originally Posted by acoder What's the relationship between serial/parts and ticket. Is it many-to-one, i.e. many serials and parts to one ticket? Ok everytime someone inserts a ticket. ticket has one record (always), parts has one record (always) and serial can have multiple records. An there all suppose to share the same ticket like pkb_fk_ticketNo (for serial) has the same number as fk_serialNo (for parts) and pk_ticketID(for ticket). Hope that makes since, kinda hard to explain.
Thank you,
Rach
| | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: URL Method for 3 tables?
Hey Acoder,
Yes its many serials and parts to one ticket. They all share the same number in each table like if pk_ticketID (from ticket table) has the number 1, then pkb_fk_ticketNo (from serial table) has the number 1, and fk_ticketNo(from parts table) has the number 1. I figured out i had the wrong field for parts. But even changing it didn't seem to help. But here is the statement again -
<cfquery name="all" datasource="CustomerSupport">
-
SELECT *
-
FROM dbo.tbl_CS_ticketMaster,dbo.tbl_CS_serial,dbo.tbl_CS_parts
-
-
WHERE pkb_fk_ticketNo = pk_ticketID and fk_ticketNo = pk_ticketID
-
and pk_ticketID = #URL.pk_ticketID#
-
</cfquery>
-
Thank you again for all your help,
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: URL Method for 3 tables?
To make things easier, you could use 3 queries as you had earlier.
As an example: - <cfquery name="serial" datasource="CustomerSupport">
-
SELECT pka_serialNo,pkb_fk_ticketNo,model_no,product_type ,
-
software_hardware,resolution,resolution_date,
-
verification_date,rma_data,
-
type_hardware_failure,dept_responsibility,resoluti on_verified_by FROM dbo.tbl_CS_serial
-
WHERE pkb_fk_ticketno = #url.pk_ticketID#
-
</cfquery>
Then you can get the serial and parts data separately.
| | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: URL Method for 3 tables? Quote:
Originally Posted by acoder To make things easier, you could use 3 queries as you had earlier.
As an example: - <cfquery name="serial" datasource="CustomerSupport">
-
SELECT pka_serialNo,pkb_fk_ticketNo,model_no,product_type ,
-
software_hardware,resolution,resolution_date,
-
verification_date,rma_data,
-
type_hardware_failure,dept_responsibility,resoluti on_verified_by FROM dbo.tbl_CS_serial
-
WHERE pkb_fk_ticketno = #url.pk_ticketID#
-
</cfquery>
Then you can get the serial and parts data separately. Hey Acoder,
Thought i understood what you meant, but i am still having trouble.It still wont only get the serial and part associated with the ticket Here is what i have. - <cfquery name="ticket" datasource="CustomerSupport">
-
SELECT pk_ticketID,title,priority,status,cost_center,fk_customer_number,
-
customer_company,customer_Fname,customer_Lname,customer_add1,
-
customer_city,customer_state,
-
customer_zip,customer_email,customer_pri_phone,customer_sec_phone,
-
customer_notes,htpp FROM dbo.tbl_CS_ticketMaster
-
WHERE pk_ticketID = #URL.pk_ticketID#
-
</cfquery>
-
-
<cfquery name="serial" datasource="CustomerSupport">
-
SELECT pka_serialNo,pkb_fk_ticketNo,model_no,product_type,software_hardware
-
,resolution,resolution_date,
-
verification_date,rma_data,type_hardware_failure,dept_responsibility
-
,resolution_verified_by FROM dbo.tbl_CS_serial
-
WHERE pkb_fk_ticketNo = #URL.pk_ticketID#
-
</cfquery>
-
-
<cfquery name="parts" datasource="CustomerSupport">
-
SELECT pk_partID,fk_serialNo,fk_ticketNo,hc_partNo,part_returned,defective
-
,submission
-
FROM dbo.tbl_CS_parts
-
WHERE fk_ticketNo = #URL.pk_ticketID#
-
</cfquery>
-
-
<cfoutput>
-
<form name="page1" id="page1" action="saveticket1edit.cfm?pk_ticketID=#pk_ticketID#"
-
method="POST" onSubmit="return validate_form();">
-
</cfoutput>
Any suggestions?
Thank you for all the help :),
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: URL Method for 3 tables?
Where's the code for outputting the data?
| | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: URL Method for 3 tables? Quote:
Originally Posted by acoder Where's the code for outputting the data? Hey Acoder,
Not sure what you mean, bit confused. i don't know if this is what you mean but here is all i have
page 1 - <!---Shows what was previously entered into table ticketmaster--->
-
<cfquery name="ticket" datasource="CustomerSupport">
-
SELECT pk_ticketID,title,priority,status,cost_center,fk_customer_number,
-
customer_company,customer_Fname,customer_Lname,customer_add1,customer_city,customer_state,
-
customer_zip,customer_email,customer_pri_phone,customer_sec_phone,customer_notes,htpp FROM dbo.tbl_CS_ticketMaster
-
WHERE pk_ticketID = #URL.pk_ticketID#
-
</cfquery>
-
-
<cfquery name="serial" datasource="CustomerSupport">
-
SELECT pka_serialNo,pkb_fk_ticketNo,model_no,product_type,software_hardware,resolution,resolution_date,
-
verification_date,rma_data,type_hardware_failure,dept_responsibility,resolution_verified_by FROM dbo.tbl_CS_serial
-
WHERE pkb_fk_ticketNo = #URL.pk_ticketID#
-
</cfquery>
-
-
<cfquery name="parts" datasource="CustomerSupport">
-
SELECT pk_partID,fk_serialNo,fk_ticketNo,hc_partNo,part_returned,defective,submission
-
FROM dbo.tbl_CS_parts
-
WHERE fk_ticketNo = #URL.pk_ticketID#
-
</cfquery>
-
-
<cfoutput>
-
<form name="page1" id="page1" action="saveticket1edit.cfm?pk_ticketID=#pk_ticketID#"
-
method="POST" onSubmit="return validate_form();">
-
</cfoutput>
an heres whats on page 2 - <cfquery name="ticket" datasource="CustomerSupport">
-
SELECT pk_ticketID,title,priority,status,cost_center,followup_date,fk_customer_number,
-
customer_company,customer_Fname,customer_Lname,customer_add1,customer_city,customer_state,
-
customer_zip,customer_email,customer_pri_phone,customer_sec_phone,customer_notes,onsite_flag,number_onsite,htpp FROM dbo.tbl_CS_ticketMaster
-
WHERE pk_ticketID = #URL.pk_ticketID#
-
</cfquery>
-
-
<cfquery name="serial" datasource="CustomerSupport">
-
SELECT pka_serialNo,pkb_fk_ticketNo,model_no,product_type,software_hardware,resolution,resolution_date,
-
verification_date,rma_data,type_hardware_failure,dept_responsibility,resolution_verified_by FROM dbo.tbl_CS_serial
-
</cfquery>
-
-
<cfquery name="parts" datasource="CustomerSupport">
-
SELECT pk_partID,fk_serialNo,fk_ticketNo,hc_partNo,part_returned,defective,submission
-
FROM dbo.tbl_CS_parts
-
-
-
</cfquery>
Thank you,
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: URL Method for 3 tables?
You mentioned in the first post that you're able to get one table of information, but not three. When you get the table data using cfquery, you must be using it somewhere, e.g. cfoutput, cfloop to display it or otherwise make use of it. Also, what's the purpose of that form?
| | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: URL Method for 3 tables? Quote:
Originally Posted by acoder You mentioned in the first post that you're able to get one table of information, but not three. When you get the table data using cfquery, you must be using it somewhere, e.g. cfoutput, cfloop to display it or otherwise make use of it. Also, what's the purpose of that form? Hey Acoder,
Ok here is how i do it.
On the index.cfm page i have this. - <cfquery name="ticket" datasource="CustomerSupport">
-
SELECT pk_ticketID,status,title,date_last_modified,date_submitted,
-
customer_company FROM dbo.tbl_CS_ticketMaster
-
</cfquery>
-
-
<cfoutput query="ticket">
-
<a href="form/cticketpage1edit.cfm?pk_ticketID=#pk_ticketID#" target="_blank">#pk_ticketID#</a>
-
</cfoutput>
the index page basically allows the user to choose which ticket he is editing.
When you click on the link (which displays the ticket number the user is chooseing) it takes you to page 1 of the form that shows you the title of the ticket and contact information. When you click submit on the first page of the form it then takes you to the second page of the form where you see the contact information again (which it gets the contact information correctly) an then shows the serial and parts information (which is what i am trying to show). but reason we did it in 2 pages was because its a long form so didn't want to overwhelm the user.
Thank you,
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: URL Method for 3 tables?
If you're not going to use the queries on page 1, there's no need for them there. On page 2, you will need to make the modifications that you've made in page 1.
Alternatively, keep everything in page 1 and show only parts and allow other parts to be shown using JavaScript.
| | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: URL Method for 3 tables? Quote:
Originally Posted by acoder If you're not going to use the queries on page 1, there's no need for them there. On page 2, you will need to make the modifications that you've made in page 1.
Alternatively, keep everything in page 1 and show only parts and allow other parts to be shown using JavaScript. Hey Acoder,
ok i am a bit confused. so basically take out the serial and part table and move it onto the second page? i am just confused on what needs to stay and what needs to go.
Heres whats on page 1 - <cfquery name="ticket" datasource="CustomerSupport">
-
SELECT pk_ticketID,title,priority,status,cost_center,fk_customer_number,
-
customer_company,customer_Fname,customer_Lname,customer_add1,customer_city,customer_state,
-
customer_zip,customer_email,customer_pri_phone,customer_sec_phone,customer_notes,htpp FROM dbo.tbl_CS_ticketMaster
-
WHERE pk_ticketID = #URL.pk_ticketID#
-
</cfquery>
-
-
<cfquery name="serial" datasource="CustomerSupport">
-
SELECT pka_serialNo,pkb_fk_ticketNo,model_no,product_type,software_hardware,resolution,resolution_date,
-
verification_date,rma_data,type_hardware_failure,dept_responsibility,resolution_verified_by FROM dbo.tbl_CS_serial
-
WHERE pkb_fk_ticketNo = #URL.pk_ticketID#
-
</cfquery>
-
-
<cfquery name="parts" datasource="CustomerSupport">
-
SELECT pk_partID,fk_serialNo,fk_ticketNo,hc_partNo,part_returned,defective,submission
-
FROM dbo.tbl_CS_parts
-
WHERE fk_ticketNo = #URL.pk_ticketID#
-
</cfquery>
-
-
<cfquery name="parts" datasource="CustomerSupport">
-
SELECT pk_partID,fk_serialNo,fk_ticketNo,hc_partNo,part_returned,defective,submission
-
FROM dbo.tbl_CS_parts
-
</cfquery>
-
<cfoutput>
-
<form name="page1" id="page1" action="saveticket1edit.cfm?pk_ticketID=#pk_ticketID#"
-
method="POST" onSubmit="return validate_form();">
-
</cfoutput>
Thank you,
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: URL Method for 3 tables?
You can remove those queries from page 1 and put them in page 2.
| | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: URL Method for 3 tables? Quote:
Originally Posted by acoder You can remove those queries from page 1 and put them in page 2. Hey Acoder,
Wow can't believe it was so simple! THANK YOU THANK YOU, YOUR AWESOME!!! If you don't mind me asking just one more question. Ok i been running into a problem where if someone does not fill out a field it doesn't show the field at all. It will show the name next to the field, but the field itself no an was wondering how would i make the field still show up even with a value applied to the field.
Example - <input type="text" name="serialnum_' + count + '" value="#pka_serialNo#">
I have tried - <cfparam name="Form.pka_serialNo" default="">
but because i have a value applied to it, it don't work so was wondering if there was a work around.
Thank you again,
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: URL Method for 3 tables?
The user wouldn't be entering the pk_serialno value, would they? Is pka_serialNo a query value or a form variable?
| | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: URL Method for 3 tables? Quote:
Originally Posted by acoder The user wouldn't be entering the pk_serialno value, would they? Is pka_serialNo a query value or a form variable? Hey Acoder,
the pka_serialNo is the query value. I tried to put the serialnum_ as the name but ran into trouble with that as well.
Thank you,
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: URL Method for 3 tables?
Can you show the rest of the code that displays the query data?
| | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: URL Method for 3 tables? Quote:
Originally Posted by acoder Can you show the rest of the code that displays the query data? Hey Acoder,
Its the same code i been showing you in the how to loop through this post. What happens is basically i have one record where someone didn't enter anything in the serial table or parts table an basically the serial table don't show up and some parts of the parts table shows up. An although nothing was entered in either it still needs to show up the field as blank (like if you click on add serial it shows all the fields blank). However, it instead just shows nothing. Here is what i have
Thank you,
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: URL Method for 3 tables?
Although this may not solve the problem, I've noticed code that may be part of the problem and will no doubt cause problems in the future. Where you have code like: - name="serialnum_' + count + '"
needs to be replaced with
You forgot to translate some of the JavaScript when converting.
| | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: URL Method for 3 tables? Quote:
Originally Posted by acoder Although this may not solve the problem, I've noticed code that may be part of the problem and will no doubt cause problems in the future. Where you have code like: - name="serialnum_' + count + '"
needs to be replaced with
You forgot to translate some of the JavaScript when converting. Hey Acoder,
Yeah i was going to ask you about the count towards the end, but probably should of asked that earlier. But that still didn't solve the problem. here is what i have
Thank you,
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: URL Method for 3 tables?
Oh right, if you have no data in the table, it's not going to show whatever code is in the loop. What you can do is add a check for the recordcount. If it's 0, show the blank fields.
| | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: URL Method for 3 tables? Quote:
Originally Posted by acoder Oh right, if you have no data in the table, it's not going to show whatever code is in the loop. What you can do is add a check for the recordcount. If it's 0, show the blank fields. Hey Acoder,
Bit confused on what you mean with the recordcount? are you meaning to do something like - <cfparam name="Form.recordcount" default="">
Thank you,
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: URL Method for 3 tables?
No, the recordcount of the serial query, i.e. check serial.recordcount is 0.
| | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: URL Method for 3 tables? Quote:
Originally Posted by acoder No, the recordcount of the serial query, i.e. check serial.recordcount is 0. Hey Acoder,
so like this - <cfparam name="serial.recordcount" default="0">
or does it need to be somewhere else?
Thank you,
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: URL Method for 3 tables?
You don't need to use cfparam. Use cfif to check the query recordcount.
| | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: URL Method for 3 tables? Quote:
Originally Posted by acoder You don't need to use cfparam. Use cfif to check the query recordcount. Hey Acoder,
so something like this - <cfif serial.recordcount is 0/>
an does it need to be up with the cfparam or does it need to be somewhere else?
Thank you,
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: URL Method for 3 tables?
Don't close it with / - close with a </cfif>
Put it wherever you want to display the empty fields (obviously including the HTML within the tags).
| | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: URL Method for 3 tables? Quote:
Originally Posted by acoder Don't close it with / - close with a </cfif>
Put it wherever you want to display the empty fields (obviously including the HTML within the tags). Hey Acoder,
its still not working. An i have also noticed that if i try to click add serial it gives me an error an it takes me to this line in the javascript - var count = (document.getElementById('theValue').value -1)+ 2;
an continues to basically lead me to anything that involves count. but here is the
div part of it again.
Thank you,
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: URL Method for 3 tables?
The JavaScript should be something like: - var count = parseInt(document.getElementById('theValue').value) +1;
The recordcount check should contain HTML code.
| | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: URL Method for 3 tables? Quote:
Originally Posted by acoder The JavaScript should be something like: - var count = parseInt(document.getElementById('theValue').value) +1;
The recordcount check should contain HTML code. Hey Acoder,
Well i am sadly still having problems. For some reason when i fixed the ending div tag to be outside the cfoutput it now has the parts part of my table working (its below this part in another table), before it would not even display those fields as having nothing applied to them, but for some reason the table don't wanna look right for it. But anyway so are you saying to wrap the html in the cfif for example - <cfif serial.recordcount is 0>
-
<table class="zpExpandedTable" id="modeltable">
-
<th class="sectiontitletick" colspan="7">
-
Serial Information #count# </th>
-
<tr>
-
<td id="paddingformultitop">Model No: </td>
-
</td>
-
<td>
-
<select name="modelno_#count#">
-
<option value="">Make A Selection</option>
-
<cfloop query="models">
-
<option value="#model#"<cfif #model# is #model_no#>selected</cfif>>#model#</option>
-
</cfloop>
-
</select>
-
</td>
-
</tr>
-
</table>
-
</cfif>
i been trying this an it doesn't seem to do anything to it. An i don't know if this helps but if i try to click on add serial it says object required.
Thank you,
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: URL Method for 3 tables?
What I was suggesting was to put the HTML for the blank fields in the cfif, e.g. - <!--- code that displays in loop for serials and parts --->
-
<!--- ... --->
-
<!--- now if no serials, then display empty table --->
-
<cfif serial.recordcount is 0>
-
<table class="zpExpandedTable" id="modeltable">
-
<th class="sectiontitletick" colspan="7">
-
Serial Information 1 </th>
-
<tr>
-
<td id="paddingformultitop">Model No: </td>
-
</td>
-
<td>
-
<select name="modelno_1">
-
<option value="">Make A Selection</option>
-
<cfloop query="models">
-
<option value="#model#">#model#</option>
-
</cfloop>
-
</select>
-
</td>
-
</tr>
-
</table>
-
</cfif>
| | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: URL Method for 3 tables? Quote:
Originally Posted by acoder What I was suggesting was to put the HTML for the blank fields in the cfif, e.g. - <!--- code that displays in loop for serials and parts --->
-
<!--- ... --->
-
<!--- now if no serials, then display empty table --->
-
<cfif serial.recordcount is 0>
-
<table class="zpExpandedTable" id="modeltable">
-
<th class="sectiontitletick" colspan="7">
-
Serial Information 1 </th>
-
<tr>
-
<td id="paddingformultitop">Model No: </td>
-
</td>
-
<td>
-
<select name="modelno_1">
-
<option value="">Make A Selection</option>
-
<cfloop query="models">
-
<option value="#model#">#model#</option>
-
</cfloop>
-
</select>
-
</td>
-
</tr>
-
</table>
-
</cfif>
Hey Acoder,
Hate to say it i am still confused. By looking at your example your implying to change modelno_#count# to modelno_1 an the thing is i still need the count there because it will have to be able to display previously entered records and also fields that they did not enter. an confused by also taking out the selected since i need the selected to show what the user selected as there option. But here is what i have. Now the add serial works correctly with no problems :). But here is what i have, bolded what is new.
Thank you,
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: URL Method for 3 tables?
I didn't mean to replace what you currently had, but to add to it.
However, before going any further, can you confirm that you definitely need to have something displayed for serials and parts even if there are none for a particular ticket?
| | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: URL Method for 3 tables? Quote:
Originally Posted by acoder I didn't mean to replace what you currently had, but to add to it.
However, before going any further, can you confirm that you definitely need to have something displayed for serials and parts even if there are none for a particular ticket? Hey Acoder,
its ok about the replacing just making sure i can still keep it in there :).
But yes i definitely have to have something display there for serial an parts even if there was nothing applied to it to begin with. Need it because they might need to later add on to the form and if the field is not available to type in then they can't add on to it.
Thank you,
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: URL Method for 3 tables?
In that case, you need to keep what you had before (without the cfif) and then copy and add after <cfloop query="serial"> the <cfif recordcount ...> code. What this would do is show the previous serials if any and if none, it would display an empty table for the user to fill.
| | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: URL Method for 3 tables? Quote:
Originally Posted by acoder In that case, you need to keep what you had before (without the cfif) and then copy and add after <cfloop query="serial"> the <cfif recordcount ...> code. What this would do is show the previous serials if any and if none, it would display an empty table for the user to fill.
Hey Acoder
so your saying to do to every field this - <select name="modelno_#count#">
-
<option value="">Make A Selection</option>
-
<cfloop query="models"><cfif serial.recordcount is 0>
-
<option value="#model#"<cfif #model# is #model_no#>selected</cfif>>#model#</option>
-
</cfif>
-
</cfloop>
-
</select>
or something else? but here is everything inside the div, haven't added the <cfif serial.recordcount is 0> to them all yet
Thank you,
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: URL Method for 3 tables?
No, just one recordcount check and all tables/fields included, but blank and nothing selected.
| | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: URL Method for 3 tables? Quote:
Originally Posted by acoder No, just one recordcount check and all tables/fields included, but blank and nothing selected. Hey Acoder,
I tried this but i know this aint right i guess i am just confused on where i should put it. bolded where i put them
Thank you,
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: URL Method for 3 tables?
No, remove the cfif around the code there and do something like: - <!--- previous code without cfif then ...--->
-
<cfif serial.recordcount is 0>
-
<!--- display empty table --->
-
</cfif>
| | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: URL Method for 3 tables? Quote:
Originally Posted by acoder No, remove the cfif around the code there and do something like: - <!--- previous code without cfif then ...--->
-
<cfif serial.recordcount is 0>
-
<!--- display empty table --->
-
</cfif>
Hey Acoder,
did that. Do i need to put inbetween the cfif a copy of everything above it except make the fields not have a value? here is what i have. bolded where i added it.
Thank you,
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: URL Method for 3 tables?
Yes, now add the same code within the cfif. Of course, you could make things easier by putting it in a separate file and including using cfinclude to reduce redundancy or use a custom tag.
| | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: URL Method for 3 tables? Quote:
Originally Posted by acoder Yes, now add the same code within the cfif. Of course, you could make things easier by putting it in a separate file and including using cfinclude to reduce redundancy or use a custom tag. Hey Acoder,
Yeah i might do an include when its all done i got 1136 lines of code. If i could move the javascript into its own file it would help a lot but when i tried it ran into problems. But anyway here is what i did but still getting the same thing. heres everything between cfif
Thank you,
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: URL Method for 3 tables?
No, the cfif must be outside the cfoutput query unless this is copied code and the previous code is untouched in which case you need to remove all code which references the query and its fields because there are no records.
One possibility that might make sense here is to have one file which contains the table and you set the variables before you call the file. This would avoid this repetition in the code which feels wrong and looks ugly.
Note that Coldfusion generates the JavaScript, so you can't move that into its own file unless it's a Coldfusion file rather than a JavaScript one.
| | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: URL Method for 3 tables? Quote:
Originally Posted by acoder No, the cfif must be outside the cfoutput query unless this is copied code and the previous code is untouched in which case you need to remove all code which references the query and its fields because there are no records.
One possibility that might make sense here is to have one file which contains the table and you set the variables before you call the file. This would avoid this repetition in the code which feels wrong and looks ugly.
Note that Coldfusion generates the JavaScript, so you can't move that into its own file unless it's a Coldfusion file rather than a JavaScript one. Hey Acoder,
Yes the previous code has been untouched (just copied everything from the previous into the cfif. But i got it to display with nothing applied to it. But i must admit i am now having the trouble i had with serial with my parts table. i thought solving serial would solve parts but didn't an having trouble with it (exact same trouble with displaying it with no value applied).
an since i am having the same trouble with parts like serial and i would really hate to have 2 sections of code repeated twice to do this so i was wondering how would i go about making the file which contains the table and set s the variables before calling the file?
but yeah i figured i couldn't move the javascript based on the fact that it uses html and coldfusion. I moved other parts of the form into there own table but was only able to do those because didn't need anything from the html or coldfusion.
Thank you,
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: URL Method for 3 tables?
If the parts and serials tables are significantly different, you're going to have to create two files anyway. Set all the values before including the file (which you're doing now anyway) and set them to empty for the 0 recordcount part, e.g. - <cfoutput query="serial">
-
<!--- cfset statements --->
-
<cfinclude ...>
-
</cfoutput>
-
<cfif serial.recordcount is 0>
-
<!--- cfset statements similar to above but set to "" --->
-
<cfinclude ...>
-
</cfif>
| | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: URL Method for 3 tables?
Hey Acoder,
Ok well here is what i got. But i got one question, was i suppose to use the value i assigned to each field or use the field name? i used the value i gave each field for this because was not sure. - serial table
-
<cfoutput query="serial">
-
<cfset model_no = #model_no#>
-
<cfset product_type = #product_type#>
-
<cfset type_hardware_failure = #type_hardware_failure#>
-
<cfset pka_serialNo = #pka_serialNo#>
-
<cfset software_hardware = #software_hardware#>
-
<cfset description = #description#>
-
<cfset resolution = #resolution#>
-
<cfset resolution_date = #resolution_date#>
-
<cfset resolution_verified_by = #resolution_verified_by#>
-
<cfset verification_date = #verification_date#>
-
<cfset dept_responsibility = #dept_responsibility#>
-
<cfset rma_data = #rma_data#>
-
<cfinclude template="serialdisplay.cfm">
-
</cfoutput>
-
<cfif serial.recordcount is 0>
-
<cfset model_no = "">
-
<cfset product_type = "">
-
<cfset type_hardware_failure = "">
-
<cfset pka_serialNo = "">
-
<cfset software_hardware = "">
-
<cfset description = "">
-
<cfset resolution = "">
-
<cfset resolution_date = "">
-
<cfset resolution_verified_by = "">
-
<cfset verification_date = "">
-
<cfset dept_responsibility = "">
-
<cfset rma_data = "">
-
</cfinclude>
-
</cfif>
-
-
parts table
-
<cfoutput query="parts">
-
<cfset hc_partNo = #hc_partNo#>
-
<cfset defective = #defective#>
-
<cfset submission = #submission#>
-
<cfinclude template="partsdisplay.cfm">
-
</cfoutput>
-
<cfif parts.recordcount is 0>
-
<cfset hc_partNo = "">
-
<cfset defective = "">
-
<cfset submission = "">
-
</cfinclude>
-
</cfif>
Thank you,
Rach
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,581
| | | re: URL Method for 3 tables?
The cfinclude should be the same for when the record count is 0, not </cfinclude>
If the field names are the same, you can remove those declarations from inside the loop.
A thought occurred to me. Could you not have empty serial/part tables/fields regardless of whether there was 0 record count or not, i.e. an empty table always appears at the end? This would get rid of the need to check for 0 record count.
| | Site Addict | | Join Date: Aug 2008 Location: United States
Posts: 769
| | | re: URL Method for 3 tables?
Hey Acoder,
well it doesn't always need a empty table at the end. Most of the time all of the fields should be filled in except a few. those few not filled in are the ones the person filling in the information has to wait on till the user there helping has there problem solved.But although i know most of the fields should be filled in, that might not always be the case which is why i am making sure all the fields can allow blanks in them. An i am afraid adding a table at the end of it all would confuse the users an they would think to delete it every time an we got some lazy people who would complain about having to do that.but here is what i got, whats the next step? - serial table
-
<cfoutput query="serial">
-
<cfset model_no = #model_no#>
-
<cfset product_type = #product_type#>
-
<cfset type_hardware_failure = #type_hardware_failure#>
-
<cfset pka_serialNo = #pka_serialNo#>
-
<cfset software_hardware = #software_hardware#>
-
<cfset description = #description#>
-
<cfset resolution = #resolution#>
-
<cfset resolution_date = #resolution_date#>
-
<cfset resolution_verified_by = #resolution_verified_by#>
-
<cfset verification_date = #verification_date#>
-
<cfset dept_responsibility = #dept_responsibility#>
-
<cfset rma_data = #rma_data#>
-
<cfinclude template="serialdisplay.cfm">
-
</cfoutput>
-
<cfif serial.recordcount is 0>
-
<cfset model_no = "">
-
<cfset product_type = "">
-
<cfset type_hardware_failure = "">
-
<cfset pka_serialNo = "">
-
<cfset software_hardware = "">
-
<cfset description = "">
-
<cfset resolution = "">
-
<cfset resolution_date = "">
-
<cfset resolution_verified_by = "">
-
<cfset verification_date = "">
-
<cfset dept_responsibility = "">
-
<cfset rma_data = "">
-
<cfinclude>
-
</cfif>
-
-
-
parts table
-
<cfoutput query="parts">
-
<cfset hc_partNo = #hc_partNo#>
-
<cfset defective = #defective#>
-
<cfset submission = #submission#>
-
<cfinclude template="partsdisplay.cfm">
-
</cfoutput>
-
<cfif parts.recordcount is 0>
-
<cfset hc_partNo = "">
-
<cfset defective = "">
-
<cfset submission = "">
-
<cfinclude>
-
</cfif>
Thank you :),
Rach
|  | | | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,471 network members.
|