Solved

Is there a way to perform a cfquery within Javascript

Posted on 2001-08-01
9
565 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
ID: 6341177
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:Scott Bennett
Scott Bennett earned 25 total points
ID: 6341369
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:Scott Bennett
ID: 6341387
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
Portable, direct connect server access

The ATEN CV211 connects a laptop directly to any server allowing you instant access to perform data maintenance and local operations, for quick troubleshooting, updating, service and repair.

 
LVL 19

Expert Comment

by:cheekycj
ID: 6341476
Server side validation is the safest way.

CJ
0
 
LVL 6

Expert Comment

by:dash420
ID: 6343948
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
ID: 6347103
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
ID: 6359100
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
ID: 10717362
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

Connect further...control easier

With the ATEN CE624, you can now enjoy a high-quality visual experience powered by HDBaseT technology and the convenience of a single Cat6 cable to transmit uncompressed video with zero latency and multi-streaming for dual-view applications where remote access is required.

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 …
Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

840 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