• 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 dropdown from mysql table

Populate dropdown from mysql table 9 years 11 months ago #31440

  • calamus
  • calamus's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 9
  • Thank you received: 1
Hi,
starting from this document:

www.rsjoomla.com/support/documentation/v...external-tables.html

I need to add a select based on some tag like this

TABLE_EXAMPLE
TAG1 -> red
TAG1 -> blue
TAG1 -> green
TAG2 -> red
TAG2 -> black

so if the select is TAG1 the dropdown show:
red
blue
green

please help!

kind regards
Piero
The administrator has disabled public write access.

Populate dropdown from mysql table 9 years 11 months ago #31463

  • cosmin.cristea
  • cosmin.cristea's Avatar
  • OFFLINE
  • Platinum Boarder
  • Posts: 756
  • Thank you received: 144
If you are trying to achieve this in RSForm!Pro, please refer to this article:
Auto populate a list from a table

Keep me posted!
My help is not official customer support. To receive your support, submit a ticket by clicking here
The administrator has disabled public write access.
The following user(s) said Thank You: calamus

Populate dropdown from mysql table 9 years 11 months ago #31489

  • calamus
  • calamus's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 9
  • Thank you received: 1
Another little problem ...
I have 5 dropdown option, some products don't have all dropdown active.
Then I try to add a CSS class to hide emty dropdown

Example for DROPDOWN_1:
if product == A {
$product = 'ProductA';
}

esle if product == B {
$product = 'ProductB';
}

esle $css = 'csshide';
}


Is there a way to add the "$css" variable to the HTML Layout? (Auto Generate Layout set to NO)

kind regards
Piero
The administrator has disabled public write access.

Populate dropdown from mysql table 9 years 11 months ago #31500

  • cosmin.cristea
  • cosmin.cristea's Avatar
  • OFFLINE
  • Platinum Boarder
  • Posts: 756
  • Thank you received: 144
You can hide empty fields with javascript, basically check how many options exist for the given select and based on this info, hide it.

e.g. (this example uses jQuery).
<script>
 
jQuery(document).ready(function($){
	// we grab all dropdowns
	var $dropdowns = $('select');
 
	$dropdowns.each(function(){
	// foreach dropdown, we get the options
		$options = $(this).find('option');
	// if the length of the array containing the options is 1 AND its value is '';
		if ($options.length == 1 && $options.val() == ''){
	// we hide it here (i used double parent(), function to go back 2 div wrappers);
			$(this).parent().parent().hide();
		};
	});
});
 
</script>

This code needs to be used in the CSS and Javascript section of the component.
My help is not official customer support. To receive your support, submit a ticket by clicking here
Last Edit: 9 years 11 months ago by cosmin.cristea.
The administrator has disabled public write access.
The following user(s) said Thank You: calamus

Populate dropdown from mysql table 9 years 11 months ago #31504

  • calamus
  • calamus's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 9
  • Thank you received: 1
Spectacular!!!
Thanks

I change only
$(this).parent().parent().hide();
in
$(this).parent().parent().parent().hide();

to hide also the label

kind regards
Piero
Last Edit: 9 years 11 months ago by calamus.
The administrator has disabled public write access.

Populate dropdown from mysql table 9 years 11 months ago #31505

  • cosmin.cristea
  • cosmin.cristea's Avatar
  • OFFLINE
  • Platinum Boarder
  • Posts: 756
  • Thank you received: 144
glad that I could help!
My help is not official customer support. To receive your support, submit a ticket by clicking here
The administrator has disabled public write access.

Populate dropdown from mysql table 9 years 11 months ago #31541

  • calamus
  • calamus's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 9
  • Thank you received: 1
Hi,
the form is 99% done!
Last question ... I have 5 dropdown, if all are empty I need to hide a FREETEXT field.

thanks in advance
Piero
The administrator has disabled public write access.

Populate dropdown from mysql table 9 years 11 months ago #31545

  • cosmin.cristea
  • cosmin.cristea's Avatar
  • OFFLINE
  • Platinum Boarder
  • Posts: 756
  • Thank you received: 144
Maybe there are other ways to achieve this, however (something raw) from the top of my head. I would create an empty array and push the hidden dropdown items inside - afterwards create a condition and if it's met, hide the needed div.

Example:
<script>
 
jQuery(document).ready(function($){
	// we grab all dropdowns
	var $dropdowns = $('select');
  var $hiddenDropdowns = [];
	$dropdowns.each(function(){
	// foreach dropdown, we get the options
		$options = $(this).find('option');
	// if the length of the array containing the options is 1 AND its value is '';
		if ($options.length == 1 && $options.val() == ''){
	// we hide it here (i used double parent(), function to go back 2 div wrappers);
			$(this).parent().parent().hide();
			$hiddenDropdowns.push(this);
		};
	});
	if ($hiddenDropdowns.length == '5') {
	// change .rsform-block-textarea to whatever you need to hide.
		$('.rsform-block-textarea').hide();
	}
});
 
</script>

Let me know if it works!
My help is not official customer support. To receive your support, submit a ticket by clicking 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!