Change Repeatable Form Field Type Dropdown Values

For Joomla! 3.x Coding related discussions, please use:

Moderator: ooffick

Forum rules
Please use the mailing list here: rather than this forum.
Post Reply
Joomla! Intern
Joomla! Intern
Posts: 56
Joined: Thu Mar 18, 2010 2:20 pm

Change Repeatable Form Field Type Dropdown Values

Post by sazbaztaz » Mon Mar 18, 2019 5:42 am

Hi there I'd really need some help with the following issue...

I have repeatable form field type that looks like:

Code: Select all

	<field name="user_assign"
		<fieldset hidden="true" name="user_assign_modal" repeat="true">
			<field name="user" query="SELECT id, CONCAT(firstname, ' ', lastname)AS fullname FROM #__mxd_users WHERE owner = [USER_ID] ORDER BY firstname ASC" key_field="id" value_field="fullname" type="sql" required="false" label="Select User" description="Select user to assign.">
				<option value="">Please select...</option>
			<field name="allocated_hours"
				label="Allocated Hours"
				type="text" />
The field gets rendered in my form and is repeatable there are no issues with that. What I need to do however is change the "user" dropdown values on the CLIENT SIDE by ajax depending on the value of another dropdown selected.

Tried this approach as a test but it does not work...

Code: Select all

//options fetched from server via ajax
var newOptions = {"Option 1": "value1",
  "Option 2": "value2",
  "Option 3": "value3"
var el = jQuery("select#jform_user");
el.empty(); // remove old options
jQuery.each(newOptions, function(key,value) {
	.attr("value", value).text(key));

jQuery('select#jform_user').trigger( "liszt:updated" );
jQuery('select#jform_user').trigger( "change" );
I assume the option values are stored somwhere in a javascript variable... Any help would be much appreciated.

Post Reply

Return to “Joomla! 3.x Coding”