?
Solved

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

Posted on 2003-03-19
13
Medium Priority
?
193 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 
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

Flexible connectivity for any environment

The KE6900 series can extend and deploy computers with high definition displays across multiple stations in a variety of applications that suit any environment. Expand computer use to stations across multiple rooms with dynamic access.

Question has a verified solution.

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

This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses
Course of the Month10 days, 11 hours left to enroll

765 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