more than one separate value?

By: Thomas Kutscher | Asked: 02/20/2024
ForumsCategory: How-tomore than one separate value?
Thomas Kutscher asked 9 months ago

Dear all,

i have a dropdown field with multiple Names. Each name has an unique email-address and an unique number.

Target: when the user select a name, the corresponding email and number should be filled automatically in separate fields. As read only.

One value - e.g. email-address - is no problem. Just by addressing (calculating) the "separate value" of the dropdown list. But how can i address one more "separate value"?

 

I hope you understand what i mean... 😉   Thanks so much, tom

1 Answers
Rob LeVineRob LeVine answered 9 months ago

I'm going to say that that is a non-standard use of "separate values", but I'm sure others have done similar too.  I would use jQuery and when the user is selected, you pass the user ID, via an Ajax call, to a PHP program that looks up the user and returns his/her email address and unique number.  The jQuery code then sets the value of the two read-only fields to the values returned by the Ajax call.  Another option, using jQuery without the need for Ajax is change your "separate values" to be "email_address[some delimited]unique_number", e.g., [email protected]|456.  When the user selects a value, you can use jQuery to split the string by the delimiter and assign the values to the read-only fields.  That being said, two things: 1. I'm not clear how you set up your separate values in the first place and 2. There may be a way without any custom code, and I'm not thinking of it.

Thomas Kutscher replied 9 months ago

thank you so much. I will try the "delimiter"-way 🙂

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right