473,407 Members | 2,598 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Validating Insert Query

219 100+
I've got an enter/edit screen created for people to enter new systems. Before the new system gets submitted I have the submit page query the database to make sure that a record doesn't already exist with that name. If it does, I set the url back to the enter/edit screen. Is there a way I can have the coldfusion popup a message stating that the user entered an entry that already exists?

Here is a snipped from the submit page:

Expand|Select|Wrap|Line Numbers
  1. <cfif isDefined("Form.Add")>
  2.     <cfquery name="validateName" datasource="Security_Access" dbtype="ODBC">
  3.         select sysID from tblSystem
  4.         where name='#Form.name#'
  5.     </cfquery>
  6.     <cfif "validateName.RecordCount" eq 1>
  7.         <cflocation URL="system.cfm">
  8.     <cfelse>
  9.         .................
  10.  
Sep 27 '07 #1
5 3229
acoder
16,027 Expert Mod 8TB
You can popup a message using JavaScript. You could pass a variable in the url to show that validation failed and check that to show the popup in the original page.

Alternatively, just show an error message on screen.
Sep 27 '07 #2
dmorand
219 100+
Excellent thanks!!

Will CF create the javascript for me? I don't really know javascript all that well, so I've been relying on the javascript that CF creates.
Sep 27 '07 #3
acoder
16,027 Expert Mod 8TB
Excellent thanks!!

Will CF create the javascript for me? I don't really know javascript all that well, so I've been relying on the javascript that CF creates.
If you just want a simple alert, the Javascript is very easy, e.g.
Expand|Select|Wrap|Line Numbers
  1. alert("You entered an entry that already exists!");
Of course, you would use Coldfusion to check first and then put the Javascript within <script> tags, e.g.
Expand|Select|Wrap|Line Numbers
  1. <cfif isDefined("url.error")>
  2. <script>...</script>
  3. </cfif>
Sep 28 '07 #4
acoder
16,027 Expert Mod 8TB
One other alternative is to post to the same page, i.e. your form and action pages are the same. In this way, if there is an error, you can display the alert and then display the form again, instead of using cflocation.
Sep 28 '07 #5
dmorand
219 100+
One other alternative is to post to the same page, i.e. your form and action pages are the same. In this way, if there is an error, you can display the alert and then display the form again, instead of using cflocation.
That's a good idea, I should look into implementing that.
Sep 28 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

13
by: David Gray | last post by:
Greetings all, Quick newbie type question: I would like to be able to trap non-numerical data entered into a textbox via CTRL+C and/or Shift+Insert. I realise that this data can be...
0
by: Morné | last post by:
Hi how do I validate a text value in a datagrid e.g. the user is only allowed to type in a Y or a N. I specifically have a problem with using the PropertyDescriptorCollection. I get the...
3
by: Shapper | last post by:
Hello, I have created 3 functions to insert, update and delete an Access database record. The Insert and the Delete code are working fine. The update is not. I checked and my database has all...
2
by: Geoffrey KRETZ | last post by:
Hello, I'm wondering if the following behaviour is the correct one for PostGreSQL (7.4 on UNIX). I've a table temp_tab with 5 fields (f1,f2,f3,...),and I'm a launching the following request :...
7
by: David Bear | last post by:
I have a dictionary that contains a row of data intended for a data base. The dictionary keys are the field names. The values are the values to be inserted. I am looking for a good pythonic...
5
by: ameen.abdullah | last post by:
Hi Guys, I have a textbox in windows form that should only accept alphabets, numbers, spaces and underscore. If the textbox contains anyother character it should display a msg at the time of...
6
by: rn5a | last post by:
During registration, users are supposed to enter the following details: First Name, Last Name, EMail, UserName, Password, Confirm Password, Address, City, State, Country, Zip & Phone Number. I am...
13
by: anuradha135 | last post by:
I have a textarea in my jsp, where in the user will enter a sql query of select or insert or update or delete.I have to validate that entered data and say whether the query is syntatically correct...
5
by: satyabhaskar | last post by:
hi all, In my web page i have created radio buttons dynamically on to the page .....following is my code string Course, Semester, Section; int rowsCount; string con =...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.