Auto populate a drop down from a text field

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Andy Gassmann
    New Member
    • Dec 2010
    • 3

    Auto populate a drop down from a text field

    Hi. I have a text field called "Sales_Order_Nu mber" where a user can type in a sales order number. Then I also have a drop down menu called "Sales_Opti ons" which is the Sales Status of a quote if it's Open, Ordered, Closed, or Pending.
    How do I write the code so that the Sales Status field will be automatically updated to "Ordered" if something is entered in the Sales Order Number field?
    I found the java script on how to Auto populate a text box from what was chosen in the drop down menu, but now I just need to reverse this code and just have anything entered into the sales order number field. Here's the link I found this on:
    http://www.bigresource .com/Tracker/Track-javascripts-ilXLt5Yz/

    Can someone please help me?

    Thanks.
    Andy
  • JKing
    Recognized Expert Top Contributor
    • Jun 2007
    • 1206

    #2
    Is there a database involved in any of this?

    Are you checking to see if sales order numbers exist or will any information entered into the text field change the status to ordered?

    Comment

    • Andy Gassmann
      New Member
      • Dec 2010
      • 3

      #3
      Yes, there is a database where the drop down list is being populated from. Here's the code for the sales order number field box and the drop down for the Sales Status below. Basically, if anything is typed into the sales order number field, it will change the sales status to Ordered. There should only be numbers typed into the Sales Order Number field.

      Code:
      <tr>
      <td class="edit" align="right">Sales Order Number:</td>
      <td>
      <cfinput type="Text" name="Sales_Order_Number" value="#Trim(Sales_Order_Number)#" size="12" validate="integer" required="no" message="You must enter a valid number in the Sales Order Number field">
      </td>
      </tr>
      
      
      <tr>
      <td class="edit" align="right">Sales Status:</td>
      <td>
      <select name="Sales_Options">
       <cfloop query="ShowSalesStatus">
       <option value="#Sales_Options#" 
       <cfif #ShowSalesStatus.Sales_Options# EQ #ShowItem.Sales_Status#>selected</cfif>>#Sales_Options#
       </cfloop>
       </select>	  
        </td>		
        </tr>
      Last edited by acoder; Dec 17 '10, 11:42 AM. Reason: Please use [code] tags when posting code

      Comment

      • Andy Gassmann
        New Member
        • Dec 2010
        • 3

        #4
        I think I am almost there, but don't quite know how to get this to work exactly. I am able to type something into a text box and update the drop down menu, but that only works if I type in the exact value that is in the option value in the drop down menu item. How do I get this to work if I just type anything into the text box and have it populate the drop down menu with what I need? For example, what works now is if I type in 3.00 into the name box, the drop down menu goes to "gamma" after I click the company box. How can I get it to work to just type anything into the name box and have it populate the drop down menu to the option I want it to go to? Here's my code so far:

        Code:
        <form name=userform>
        
        
        Name:     <input type=text name=name size=15 value="" onChange="this.form.userid.value=this.value;"><br>
        
        Company: <input type=text name=Company size=15 valu=""
        <br>
        
        User ID: 
        <select name=userid onChange="this.value=this.form.name.value;">
        <option value="">--none--</option>
        <option value="2.50">alpha</option>
        <option value="1.95">beta</option>
        <option value="3.00">gamma</option>
        </select>
        <p>
        <input type=button name=action value="Done!">
        </form>
        Last edited by acoder; Dec 17 '10, 11:43 AM. Reason: Added [code] tags

        Comment

        Working...