Solved

Is there a way to perform a cfquery within Javascript

Posted on 2001-08-01
9
561 Views
Last Modified: 2013-12-24
I have a form that when you submit the "add" it executes javascript to validate the entered data.  I would like to validate that the record that the user is trying to add does not already exist in the database (Oracle).  Is there a way to stay on the same form and display an alert if there is match found on the database?
0
Comment
Question by:lindadudley
9 Comments
 
LVL 19

Accepted Solution

by:
cheekycj earned 25 total points
Comment Utility
do you mean without submitting.. well one option is to query your oracle DB to create a JS array of the primary key.

Then validate against that array before the user submits.. but remember.. if a user has JS disabled.. you are out of luck.

CJ
0
 
LVL 14

Assisted Solution

by:SBennett
SBennett earned 25 total points
Comment Utility
Another point to be aware of is that if you create a JS array of the user names then if the user views the source code and know anything about javascript, they will be able to see a list of every user name in your system.

I would suggest submitting the form and doing a server-side validation.

-Scott

0
 
LVL 14

Expert Comment

by:SBennett
Comment Utility
Also, FYI - There is no way for you to do a query against your Oracle database on the client-side. All your queries must be done on the server side.
0
 
LVL 19

Expert Comment

by:cheekycj
Comment Utility
Server side validation is the safest way.

CJ
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 6

Expert Comment

by:dash420
Comment Utility
In my point view it is always to check this after in separate page i.e. which page ur going to insert into database.
:-)
0
 

Expert Comment

by:MikeForbes
Comment Utility
I agree whole-heartedly.  I usually will add code to the page that will be doing my insert/update, something like:

<cfquery datasource=#dsname# name="Test">
Select name_id, name
from table
where name_id = #form.name_id#
</cfquery>

<CFIF #Test.RecordCount# GT 0>
Hey, you already exist!
<input type="button" value="Back" onclick="history.back(-1);">
<cfabort>
</cfif>

Mike
0
 
LVL 5

Expert Comment

by:Yog
Comment Utility
Is it browser specific.

If not, try using the Microsoft.XMLHTTP component. Pretty cool but will work in IE5.0 and above only..

cheers.
0
 
LVL 9

Expert Comment

by:CFDevHead
Comment Utility
lindadudley,
No comment has been added lately (972 days), so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area for this question:

RECOMMENDATION: split points between cheekycj, SBennett,  dash420 and MikeForbes

Please leave any comments here within 4 days.

-- Please DO NOT accept this comment as an answer ! --

Thanks,

CFDevHead
EE Cleanup Volunteer
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now