mopar003
asked on
cfquery within a cfscript
Is there any way to perform the below function? I know this particular way does not work, but is there a way to mimic what this would do?
<cfscript>
/*validate form data*/
if(form.ProjectName EQ "") { err1 = "class=err"; }
if(form.FirstName EQ "") { err2 = "class=err"; }
if(form.LastName EQ "") { err3 = "class=err"; }
if(form.Department EQ "") { err4 = "class=err"; }
if(form.Email EQ "") { err5 = "class=err"; }
if(err1&err2&err3&err4&err5 NEQ "") {
WriteOutput("Error occurred. Please check the highlighted fields.");
} else {
<cfquery name="insertDesign" datasource="shssrDesignRequest">
INSERT INTO DesignRequest
(ProjectName, ProjectDescription, RequesterName)
VALUES ('#form.ProjectName#', '#form.ProjectDescription#', '#form.ad_fname# #form.ad_lname#')
</cfquery>
}
</cfscript>
why do you want use <cfscript> It will perfectly fit in withing coldfusion code
ASKER
I would prefer to use the cfscript for long bulk scripting. The code above is a snippet of the actual in use code. I am unsure of a query item being run in the script tag however. The code included should give someone an idea of what I am looking to do.
I agree with you mopar.. cfscript is much more readable...
k.. so funny thing is, I just found this out today... but if you want to use tags that aren't available in cfscript, you have to create a function.. so here is your code... standby..
k.. so funny thing is, I just found this out today... but if you want to use tags that aren't available in cfscript, you have to create a function.. so here is your code... standby..
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Good solution to the problem. A lot of workaround, unfortunately, but useful none the less. Thanks you for your help.
True... extra work... but hey... now that function is reusable if you stick it in a cfc AND its out of the way... not muckn' up your pretty code ;)