[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2011-10-24
4
Medium Priority
?
175 Views
Last Modified: 2012-05-12
    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.


0
Comment
Question by:jdines
  • 2
4 Comments
 
LVL 34

Expert Comment

by:Paul MacDonald
ID: 37018320
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.
0
 

Author Comment

by:jdines
ID: 37018440
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#">
0
 
LVL 52

Accepted Solution

by:
_agx_ earned 2000 total points
ID: 37019825
(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.
0
 

Author Closing Comment

by:jdines
ID: 37019861
Thank you very much
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question