Click to See Complete Forum and Search --> : Can this be done?


IndyB
09-12-2003, 04:23 PM
I'm calling the following script with a form button onClick event. I'm trying to query the DB within the script. Can this be done, and if so, am I on the right track? This is ColdFusion, but any insight any of you can provide would be great. If querying can be done, how can I properly set up the WHERE statement in my SQL query? I need it to be WHERE fullCat = "the fullCat form field value"

Any assistance is much appreciated. Thanks.

<input name="insert" type="button" onClick="checkCats()" value="Add Record">


<script language="JavaScript">
function checkCats()
{
var full_cat = document.frmAdd.fullCat.value;
var abbr_cat = document.frmAdd.Category.value;
<cfquery name="compair_cats" datasource="#request.app.dsn#">
SELECT DISTINCT urlCat, fullCat
FROM tblCatPics
WHERE fullCat = ##
</cfquery>
<cfoutput query="compair_cats">
if( '#urlCat#' != abbr_cat)
{
alert('The Long Category and Abbreviated Categories you selected to not match.');
}
else
{
document.frmAdd.submit();
}
</cfoutput>
}
</script>