PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

How to populate a single line text field based on select field value

  1. stefanweise
    Member

    I'm not a PHP deveoper, but i can make sense of most of it with a little guidance, so forgive my ignorance.

    I have a contact lens order form with a drop down field containing all of the different brands of contacts. Below that i have two rows of fields, left eye and right eye. Each row has a combination of single line text fields and dropdowns that appear if either right eye or left eye are checked. The "diameter" single text field however needs to be pre-populated with a number value based on the brand that is selected in the brand drop down field. I know that fields can be dynamically populated based on another fields' value, i just couldn't find any examples of this that would apply to my form. Also, what syntax do i need to use in the bradn drop down field for "Brand | 14.00" so that the user only sees the brand name, but the value of their choice is in fact the diameter value to be passed to the diameter single line text feild. Can anyone help me out here?

    Posted 10 years ago on Thursday April 14, 2011 | Permalink
  2. stefanweise
    Member

    Just wanted to see if anyone can help me out with this one. Thanks!

    Posted 10 years ago on Sunday April 17, 2011 | Permalink
  3. stefanweise
    Member

    Anyone?

    Posted 10 years ago on Monday April 18, 2011 | Permalink
  4. stefanweise
    Member

    Hello?

    Posted 10 years ago on Tuesday April 19, 2011 | Permalink
  5. I'm guessing nobody has any suggestions for this customization. What you want to do requires custom jQuery. Are you familiar with writing jQuery?

    Posted 10 years ago on Tuesday April 19, 2011 | Permalink
  6. stefanweise
    Member

    not too familiar with writing jQuery. I thought that this is something that PHP could handle, like a function that grabs the value and passes that to another field?

    Posted 10 years ago on Tuesday April 19, 2011 | Permalink
  7. The problem is PHP runs when the form is submitted. What you want is for code to run when a drop down is selected. That requires Javascript usage, because no form action is taking place so there is no place for the PHP to execute in that example. Javascript can run when the drop down selection is made, and then populate the field you want to populate with the value. So you would want to use jQuery.

    Unless you don't want to show the user the pre-populated value and only have it happen on submit. Is this what you want or do you want to have it be visible to the user?

    Posted 10 years ago on Tuesday April 19, 2011 | Permalink