• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 236
  • Last Modified:

Do I need to use javascript to use query data as a hidden input field?

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>

Can I do this with Coldfusion or do I have to use Javascript to accomplish this, and if so how would I do it, I am only slightly familiar with Javascript...thanks in advance for your assistance.
0
jdines
Asked:
jdines
  • 3
1 Solution
 
_agx_Commented:
You mean when an Agent is selected populate the hidden fields with the Email and AssociateCell values for the selected record? Then yes, you would need javascript.  But I would suggest a different approach. So the form works even if javascript is disabled.  

If your table has a unique record ID, add that column to your query.  Then make it the cfselect value:

<cfquery name="getAgents" datasource="teamportals"
            SELECT TheRecordID, LastName + ' ' + FirstName + ' ' + 'office ' + ' ' + Company AS Agent
            ... etc...
</cfquery>

    <cfselect query="getAgents" value="TheRecordID" display="Agent" ...>      

Then on the next page, use a query to lookup the "email" and "AssociateCell" values

   <cfquery name="getAgentValues" datasource="teamportals"
            Select AssociateCell,Email
            From tblUser
            Where TheRecordID = <cfqueryparam value="#form.agentname#" cfsqltype="cf_sql_integer">
     </cfquery>

     
   
0
 
_agx_Commented:
> the AssociateCell and Email address to be passed to the next form and posted to a table

But ... normally you don't want to duplicate data in 2 places because they get out of synch and queries may not work correctly.  For example, what would happen if the "email" changed in one table but not the other? Since the email is already stored in tblUser, typically you'd just store that table's record ID instead. Then use a JOIN when you need to retrieve the email or AssociateCell values.

          SELECT u.Email
          FROM    tblUser u INNER JOIN TheSecondTable s ON s.TheUserRecordID = s.TheUserRecordID
          WHERE ....
0
 
jdinesAuthor Commented:
Thank you, I just realized that you're the same person helping me in the other zone...thanks!!!
0
 
_agx_Commented:
I get around ;-)
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now