Topic: CFQUERY!!


][ce    -- 11-28-2003 @ 9:59 AM
  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
  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

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


EasyCFM.COM ColdFusion Forums : http://archive.easycfm.com/forums
Topic: http://archive.easycfm.com/forums/viewmessages.cfm?Forum=12&Topic=2353