• 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: Populate fields based on dropdown selection

Populate fields based on dropdown selection 13 years 11 months ago #13571

  • mrnorx
  • mrnorx's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 4
Hi I have a database table called groups with 3 fields (Name, Number, Email). I have a form with a dropdown which populates form the name field. What I need is for 2 text fields called number1 and email1 to poulate from the database when the user selects a name from the dropdown.

For example user clicks on John in the dropdown then a database query looks up john and returns the number and email into the 2 relevant fields. I dont mind if this happens with an onchange event or if it happens on form submit as long as the fields are populated and stored in the form database.

Has anyone achieved this or can anyone advise on the correct script to make this work. Im sure its straight forward but I am not great with javascript and php

Many thanks
The administrator has disabled public write access.

Re:Populate fields based on dropdown selection 13 years 11 months ago #13584

  • mrnorx
  • mrnorx's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 4
OK, I have found a script that does what i want it to.
Can anyone help me tweak this and make it fit into rs forms so it populates the text field when an onchnage function is triggered.

Edit: I figured out how to do this myself. It now makes RSforms worth having, just need to be able to send the result as a PDF.
Last Edit: 13 years 11 months ago by mrnorx. Reason: problem solved
The administrator has disabled public write access.

Re:Populate fields based on dropdown selection 13 years 11 months ago #13742

  • w_h_h
  • w_h_h's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 5
Hi mmorx!

May I ask how you solved your problem? ... I have a similar need. In my case I also want the populated fields visibale on my form but not editable .. THX!
The administrator has disabled public write access.

Re:Populate fields based on dropdown selection 13 years 10 months ago #13784

  • linku2nz
  • linku2nz's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 7
w_h_h wrote:
Hi mmorx!

May I ask how you solved your problem? ... I have a similar need. In my case I also want the populated fields visibale on my form but not editable .. THX!
If you bear with me a few days (while I tidy up the code) I may be able to help you out.

Basically, I ran some queries (a different d/b - not the Joomla one - but could be either) in the PHP script header. This script used JS "onchange" to populate the next dropdown etc.

The output field in the form needs readonly="readonly" in the "Additional Attributes" tab and the "Default Value" needs:
//<code>
$test = $_POST['form_ID'];
   return $test;
//</code>

... where "form_ID" is the form field name and id in the form in your PHP script header.

In the PHP script header, I use something like:
<select name="f_section" onchange="this.form.submit();">

The form action appears to work if blank (so it effectivley stays on the same page):
<form name="categories" method="post" action="">

This isn't complete by any means, but it may help to get you going!

Adam.
The administrator has disabled public write access.

Re:Populate fields based on dropdown selection 13 years 4 months ago #15572

Hi,

Would you be so kind and share your solution. I have a similar case where I need to load the second dropdown based on the selection on the first one, so the value from the first dropdown will be queried and result the list for the second dropdown.

any help is appreciated.
thanks.
The administrator has disabled public write access.

Re: Populate fields based on dropdown selection 13 years 3 months ago #16185

  • natselection
  • natselection's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 6
  • Thank you received: 2
Anyone find a finished solution? I have 2 dropdowns, first is a department, second is a specific job. Without some sort of way of changing the second dropdown item list based on the first selection I'd have a list of over 100 items which is just ugly and very user un-friendly.
The administrator has disabled public write access.

Re: Populate fields based on dropdown selection 13 years 2 months ago #16211

  • natselection
  • natselection's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 6
  • Thank you received: 2
Thanks to support I found the solution. demo.rsjoomla.com/dynamic-drop-down-change-form-example
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!