EasyCFM.COM ColdFusion Forums / Coding Help! / CFQUERY!!

   Reply to Discussion | New Discussion << previous || next >> 
Posted By Discussion Topic: CFQUERY!!

book mark this topic Printer-friendly Version  send this discussion to a friend  new posts last

][ce
11-28-2003 @ 9:59 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
New Member
Posts: 25
Joined: Jul 2003

Hey everybody!

I'm having a serious issue with CFQUERY... and I'm hoping somebody can shed some light.

I would like an update query to be run, only when clicking a button.  In this scenario, the button will assign a value to a field, and update the record as being used.

Although, it appears as though evereytime the page loads, the query is run, no matter what condition I put in the Javascript tag.

This is currently what I have:

<SCRIPT language="JavaScript1.2">
<!-- HIDE SCRIPT FROM OTHER BROWSERS
function GenerateAccount()
{
     <CFQUERY name="qryNewAccounts" datasource="#DSN#" dbtype="ODBC">
          SELECT TOP 1 AN.RecordID, AN.AccountNumber, AN.Used
          FROM csForms_AccountNumbers AN
          WHERE Used=0;
     </CFQUERY>

     <CFOUTPUT QUERY="qryNewAccounts">
          document.form1.AccountNumber.value = "#AccountNumber#";
     </CFOUTPUT>

     document.form1.GenAccount.disabled = true;
     document.form1.AccountNumber.locked = true;

     if(document.form1.GenAccount.disabled)
     {
          <CFQUERY name="updNewAccounts" datasource="#DSN#" dbtype="ODBC">
               UPDATE csForms_AccountNumbers SET
               Used = 1,
               DateUsed = #Now()#
               WHERE RecordID = #qryNewAccounts.RecordID#;
          </CFQUERY>
     }
}
// END OF SCRIPT -->
</SCRIPT>

Does anybody see a better way to do this?
Thanks in advance!
Dave

Webmaster
11-28-2003 @ 3:04 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Administrator
Posts: 4542
Joined: Jan 2002

First off, ColdFusion is Server-Side and what you are trying to achieve is Client-Side..

Two completly different things...

Your best option at this point would be to reload the page when they click the button and then execute the query requested.

Thanks,
Pablo Varando

=====================================================


Website Designed and Developed by Pablo Varando.