Link to home
Start Free TrialLog in
Avatar of jdines
jdinesFlag for United States of America

asked on

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.
Avatar of _agx_
_agx_
Flag of United States of America image

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>

     
   
ASKER CERTIFIED SOLUTION
Avatar of _agx_
_agx_
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jdines

ASKER

Thank you, I just realized that you're the same person helping me in the other zone...thanks!!!
I get around ;-)