• 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: Display value from dropdown in textfield

Display value from dropdown in textfield 4 years 4 months ago #40816

  • info4683
  • info4683's Avatar
  • OFFLINE
  • Junior Boarder
  • Posts: 33
  • Thank you received: 1
Hello.
I have a dropdown with entries like this:

|Please choose:[c]
john.dorian@mywebsite.com|John Dorian
max.dorian@mywebsite.com|Max Dorian
...
...

In a textfield below this dropdown I want to automatically display the value (in this case the e-mail) of the selected dropdown entry.

How can i do this?

Regards
Martin
Kaum macht man etwas richtig, schon klappt´s..
The administrator has disabled public write access.

Display value from dropdown in textfield 4 years 4 months ago #40829

  • dragos
  • dragos's Avatar
  • OFFLINE
  • Administrator
  • Posts: 634
  • Thank you received: 117
Hello,

Though not a copy paste solution, you can find a similar example on this topic here.
The administrator has disabled public write access.

Display value from dropdown in textfield 4 years 4 months ago #40834

  • info4683
  • info4683's Avatar
  • OFFLINE
  • Junior Boarder
  • Posts: 33
  • Thank you received: 1
Hello dragos,

thank you.

I have already tried this before but since the example is based on a checkbox, this gets too comlicated for me :huh:
Kaum macht man etwas richtig, schon klappt´s..
The administrator has disabled public write access.

Display value from dropdown in textfield 4 years 4 months ago #40837

  • adrianp
  • adrianp's Avatar
  • OFFLINE
  • RSJoomla! Official Staff
  • Posts: 631
  • Thank you received: 146
Hello,

Edit your dropdown > Attributes > Additional Attributes area > here you can add:
onchange="document.getElementById('exactTextboxNameHere').value=this.value;"
Replace exactTextboxNameHere with the exact name of your email textbox, case sensitive.
This is not official customer support. To receive your support, submit a support ticket here.
The administrator has disabled public write access.

Display value from dropdown in textfield 4 years 4 months ago #40838

  • info4683
  • info4683's Avatar
  • OFFLINE
  • Junior Boarder
  • Posts: 33
  • Thank you received: 1
Hello adrianp,

great - this works! Thank you!

One more question:

If I place 2 values in my dropdown (phone numer - email - text), will it be possible to copy / display the phone number and email separately in 2 textboxes with the code you suggested - maybe with a little customization?

Experimental dropdown example:

|Please choose:[c]
+44789678567|john.dorian@mywebsite.com|John Dorian
+44234345657|max.dorian@mywebsite.com|Max Dorian
...
...
Kaum macht man etwas richtig, schon klappt´s..
The administrator has disabled public write access.

Display value from dropdown in textfield 4 years 4 months ago #40840

  • adrianp
  • adrianp's Avatar
  • OFFLINE
  • RSJoomla! Official Staff
  • Posts: 631
  • Thank you received: 146
Hello,

Using two "|" pipelines on the same line won't work nor would it help. This is used to split a "value" into a "value|label" syntax - there's no third section for this as a dropdown option can only have a value and a label.

You can however take similar steps:

- the pipeline symbol will no longer help and you can remove it along with the script from the dropdown's Additional Attributes area. Basically your dropdown Items can look like this:

|Please choose:[c]
John Dorian
Max Dorian

- while editing the form > Form Properties > CSS and JavaScript > JavaScript > here add (replace field naming accordingly):
<script type="text/javascript">
function fillDetails(name){
	emailField = "myEmailFieldNameHere";
	phoneField = "myPhoneFieldNameHere";
 
	if(name == "John Dorian"){
		document.getElementById(emailField).value = "john.dorian@mywebsite.com";
		document.getElementById(phoneField).value = "+44789678567";
	}
 
	if(name == "Max Dorian"){
		document.getElementById(emailField).value = "max.dorian@mywebsite.com";
		document.getElementById(phoneField).value = "+44234345657";
	}
}
</script>

- edit your dropdown once more and place the following Additional Attribute:
onchange="fillDetails(this.value);"


PS: This is only an example, if you have too many dropdown items, the script can be normally optimized with arrays and loops.
This is not official customer support. To receive your support, submit a support ticket here.
The administrator has disabled public write access.
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!