Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

If Then HELP - big points for quick, simple and detailed return  - 250pts possible!

Posted on 2003-03-19
13
Medium Priority
?
194 Views
Last Modified: 2013-12-24
I want to check to make sure that there are NO duplicate entries in a table with a variable that is entered in a form.  What you don't see is the form which includes many input fields.  The user selects a button to submit the form and is prompted with a "Are You Sure" window.  Once the user approves the processing of the form then a SINGLE field, HNUM is compared to assure that no duplicates exist in the Oracle table. The HNUM field must be unique.

Very simply, I want an error page to be displayed (error-duplicate.cfm) if the variable in the form (form.hnum) equals that of the table hnum (duplicheck.hnum).
The code below only shows a simple test (TRUE/FALSE).  I want for the TRUE test the error-duplicate.cfm page to be displayed in a floating-type window.  If FALSE then the table will update the single record from the form.

PROBLEM: There are over 30,000 records in the table and I receive a TRUE or FALSE statement for each.  I don't want that.  I want a single true statement (error-duplicate.cfm) or a single false process to take place.

Code looks like this:

               <cfquery name="Duplicheck" datasource="gisweb" dbtype="OLEDB">
               select * from iwcgis.hydttemp
          </cfquery>
          <CFSET Duplicheck = Duplicheck>
<body>
<cfoutput query="Duplicheck">          
                              <CFIF form.HNUM eq Duplicheck.hnum>
                             
                              <font color="##FF0000">TRUE</font>
                              #form.hnum#
                              #hnum#
                             
                                   

                              <cfelse>
                                   
                             
                              FALSE
                              #form.hnum#
                              #hnum#
                             
     </CFIF>
     </cfoutput>
     </body>    
0
Comment
Question by:H2O
  • 7
  • 5
13 Comments
 
LVL 8

Expert Comment

by:TallerMike
ID: 8167415
<cfquery name="Duplicheck" datasource="gisweb" dbtype="OLEDB">
  SELECT hnum
  FROM iwcgis.hydttemp
  WHERE hnum = #form.hnum#
</cfquery>

<cfif Duplicheck.RecordCount gt 0>
  <cflocation url="error-duplicate.cfm">
</cfif>
0
 
LVL 5

Expert Comment

by:nathans
ID: 8167740
TallerMike has given you the answer... He is correct.
0
 

Author Comment

by:H2O
ID: 8168156
TallerMike ONLY (since the points are yours)

The logic works for the Edit page.

With regards to the floating window, (1) how do create it and (2) how within the error page do I add a button to return to the Edit page??


Thanks

H2O
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 8

Expert Comment

by:TallerMike
ID: 8169247
I guess I'm not sure what you mean by a floating window. Do you want a popup or a DHTML object to show up on the page like a layer?

For each type is obviously going to be a different method. The popup being the easier and more browser compliant method, and the DHTML being the more complicated and less compliant (but cool) solution.
0
 
LVL 8

Expert Comment

by:TallerMike
ID: 8169292
For the button to return you to the edit page, you've got 2 possible solutions. One is to simply use JavaScript to return you back to the previous page like so:

<input type="button" value="Back" onclick="self.history.back();">

The second option is to repost the information back to the page you came from (simply sending them back to the referrer will work as well, but they will lose any changes they made). To do this, you will need to know what page they came from (either the referrer or you'll have to send this to the error page), and then you'll need to create a hidden form on the page containing all of the form elements that were submitted to the page (loop through the form.fieldnames object and create a hidden input for each). Then your back button will simply submit this form to the page they came from. That page will then need to accept these form inputs and refill the changes the user had made.

If your form uses the GET method instead of POST, then you can just append the URL variables to the page they came from and send them there using your button, then have the page expect these variables in the URL and refill the form using them.
0
 

Author Comment

by:H2O
ID: 8169370
TallerMike ONLY (since the points are yours)

The logic works for the Edit page.

With regards to the floating window, (1) how do create it and (2) how within the error page do I add a button to return to the Edit page??


Thanks

H2O
0
 

Author Comment

by:H2O
ID: 8169461
TallerMike ONLY (since the points are yours)

The logic works for the Edit page.

With regards to the floating window, (1) how do create it and (2) how within the error page do I add a button to return to the Edit page??


Thanks

H2O
0
 
LVL 8

Expert Comment

by:TallerMike
ID: 8169535
Please don't refresh the window, this will cause you to repost your last comment. Use the "Reload This Question" link towards the top left of the page (Under your username).
0
 

Author Comment

by:H2O
ID: 8169619
TallerMike-

With regards to the floating window...

I would like the error page popup over the existing EDIT page.  Ideally, the EDIT page should not go anywhere so as when the error page is closed the EDIT page is has the current information ready for changes.

Thanks for your help thus far.

H2O
0
 
LVL 8

Expert Comment

by:TallerMike
ID: 8169699
If the edit page doesn't go anywhere, that means you'll have to submit to a popup window everytime, and if the update is OK, it will close the popup and allow the update, else it will show the message.

0
 
LVL 8

Accepted Solution

by:
TallerMike earned 1100 total points
ID: 8169734
Something like so might work for you:

Put this JavaScript function on your edit page and set the submit button to call it:

function submitErrorForm()
     {
     // Create the window popup
     editPopupWindow = window.open("checkDuplicates.cfm","editPopupWindow","height=200,width=400");
     // Make sure that the forms target is set to this popup
     document.forms[0].target = editPopupWindow;
     document.forms[0].action = "checkDuplicates.cfm";
     document.forms[0].submit();
     }

************************************************************************************************************************
************************************************************************************************************************

Then the checkDuplicates.cfm is going to run a check for duplicate records:

<cfif IsDefined("form.hnum")>
     <cfquery name="Duplicheck" datasource="gisweb" dbtype="OLEDB">
          SELECT hnum
          FROM iwcgis.hydttemp
          WHERE hnum = #form.hnum#
     </cfquery>
     
     <cfif Duplicheck.RecordCount gt 0>
          <cflocation url="error-duplicate.cfm">
     <cfelse>
          <!--- Otherwise, set the forms action to the processing page and submit the form --->
          <script language="JavaScript">
               <!--
               var parentDocument = window.opener.document;
               // Put here the page that will process the UPDATE
               document.forms[0].action = "updateEditPage.cfm";
               document.forms[0].submit();
               window.close();
               //-->
          </script>
     </cfif>
</cfif>
0
 

Author Comment

by:H2O
ID: 8170349
Thanks for going the extra mile!

Added 25 points.

Very descriptive yet straightforward.

Just like I needed.

H2O
0
 
LVL 8

Expert Comment

by:TallerMike
ID: 8170404
Thanks! No problem. I look forward to helping you in the future.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Suggested Courses

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question