cfquery within javascript


hi,

i trying following:

i wrote cfquery within javascript function below:

<script language="javascript1.2" type="text/javascript">
<cfquery name="query1 datasource="abc">
  ....
</cfquery>

<cfif query1.recordcount neq "0">
    <cfoutput query = "query1">
       <cfquery name="query2 datasource="abc">
  select * table1 name=#query1.name#
       </cfquery>
    </cfoutput>
     alert(<cfoutput>#query2.recordcount#</cfoutput>);
</cfif>
     

</script>

the alert value 1 debugging section shows 0, , 0 correct value. there wrong doing.

if can please point out...

the problem comes how cf , js work: coldfusion "server side" language while javascript "client side". means server runs through cf code in page , sends finished product on user's browser starts handling javascript.

 

i'm not sure of intended outcome ... want series of "alerts" page loads? if using alert debugging (just see being returned, can replace <p> tags , see output on screen. try this:

 

<cfif query1.recordcount neq "0">      <cfoutput query = "query1">           <cfquery name="query2 datasource="abc">           select * table1 name=#query1.name#           </cfquery>           <p>#query2.recordcount#</p>      </cfoutput> </cfif>

 

2 more notes:

  • you don't inner "cfoutput" around record output if going use cfoutpu loop on query.
  • the output line needs inside loop or you'll output last iteration.


More discussions in Advanced Techniques


adobe

Comments

Popular posts from this blog

Joomla site hacked, cant see front and - Joomla! Forum - community, help and support

Christian Home School Programs - Joomla! Forum - community, help and support

Trouble with PF_OutFlag_I_USE_AUDIO and PF_CHECKOUT_LAYER_AUDIO