Hidden Field value needs to be query result data- unsure of proper syntax.

    Hello,
I am having problems with my hidden input fields, I need for the AssociateCell and Email address to be passed to the next form and posted to a table but am unsure of how to format the hidden fields.  Here is what I have:
        <!---Agent Selection --->
     <cfquery name="getAgents" datasource="teamportals"
            Select LastName + ' ' + FirstName + ' ' + 'office ' + ' ' + Company AS Agent,AssociateCell,Email
              From tblUser
            Where Inactive = '0' AND Role ='agent'
            Order By LastName
                       
     </cfquery>
     Select Agent:&nbsp;&nbsp;  
           <cfselect name="agentname" query="getAgents" value="Agent" display="Agent" required="yes" multiple="no" size="1" >
        </cfselect>
      <br /><br />
      <input type="hidden" name="AssociateCell" value="#getAgents.AssociateCell#">
      <input type="hidden" name="Email" value="#getAgents.Email#">
       
       
        <input type="submit" name="add_btn" value = "submit">&nbsp;&nbsp;&nbsp;
        <input type="Reset" name="cancel_btn" value = "  Clear  ">
        </td>
      </tr>      
   
  </tr>
  </cfform>

This is the erro that I receive:
ODBC Error Code = 37000 (Syntax error or access violation)


[Microsoft][ODBC SQL Server Driver][SQL Server]The name 'AssociateCell#' is not permitted in this context. Only constants, expressions, or variables allowed here. Column names are not permitted.


SQL = "Insert Into savings_card (FName1,LName1,FName2,LName2,Address,City,State,Zip,Email,Phone,TransType,Agent,AssociateCell,Email, DateEntered) Values ('Mary','Jones','Other', 'User','25800 Northwestern','Somewhere','USA', '40000','xxxxx@rxxxxx.com','222-222-222,'purchase', 'Allison Daniel office 35',#getAgents.AssociateCell#,#getAgents.Email#, {d '2011-10-24'})"

Data Source = "HSO"


The error occurred while processing an element with a general identifier of (CFQUERY), occupying document position (56:3) to (56:43) in the template file D:\WebSites\HomeServices\registration_action_new.cfm.


jdinesAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Paul MacDonaldDirector, Information SystemsCommented:
You need to escape the query when using the variable values:

SQL = "Insert Into savings_card (FName1,LName1,FName2,LName2,Address,City,State,Zip,Email,Phone,TransType,Agent,AssociateCell,Email, DateEntered) Values ('Mary','Jones','Other', 'User','25800 Northwestern','Somewhere','USA', '40000','xxxxx@rxxxxx.com','222-222-222,'purchase', 'Allison Daniel office 35'," & #getAgents.AssociateCell# & ", " & #getAgents.Email# & ", {d '2011-10-24'})"

Modify the syntax for your scripting language.
jdinesAuthor Commented:
Hello,
  It is still using the actual text #getAgents.Email# and #getAgents.AssociateCell# rather than evaluating the query results and posting the actual email address and associal cell numbers to the table. I think the problem is somewhere within this block of code:
    <cfquery name="getAgents" datasource="teamportals">
         
            Select LastName + ' ' + FirstName + ' ' + 'office ' + ' ' + Company AS Agent,AssociateCell,Email
              From tblUser
            Where Inactive = '0' AND Role ='agent'
            Order By LastName
                       
     </cfquery>
     Select Agent:&nbsp;&nbsp;  
           <cfselect name="agentname" query="getAgents" value="Agent" display="Agent" required="yes" multiple="no" size="1" >
        </cfselect>
      <br /><br />
    <input type="hidden" name="AssociateCell" value="#getAgents.AssociateCell#">
      <input type="hidden" name="Email" value="#getAgents.Email#">
_agx_Commented:
(This should probably be under a CF zone) But the 1st problem is you're missing a cfoutput around the input fields. That's why you're getting the literal string "#getAgents.Email#" instead of the value.  

<cfoutput>
  <input type="hidden" name="AssociateCell" value="#getAgents.AssociateCell#">
  <input type="hidden" name="Email" value="#getAgents.Email#">
</cfoutput>

The 2nd problem is that's going to submit the same values no matter which agent is selected. The resolution to that issue is on your other thread.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jdinesAuthor Commented:
Thank you very much
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
HTML

From novice to tech pro — start learning today.