• 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: Importing data after selection | RsForms Pro

Importing data after selection | RsForms Pro 2 months 3 weeks ago #42242

Hi, I have form were by a user completes 3 fields and then based on these selections I want to load any submission which has the same in the database submissions. Can someone tell me if its possible and if my approach below is the correct way to go about it.

I have added the below code to the JavaScript section of my form:
<script>
jQuery( document ) . ready( function ( $ ) {
	// On change of the dropdown do the ajax
	$( "#site" ) . change( function () {
		processLoadFormData();		
	} );
	$( "#Child" ) . change( function () {
		processLoadFormData();		
	} );
	$( "input[name='form[Drop off Date]']" ) . change( function () {
		processLoadFormData();		
	} );
 
	function processLoadFormData(){
 
		const formId = $("input[name='form[formId]']").map(function(){return $(this).val();}).get();
		const site = $("#site").map(function(){return $(this).val();}).get();
		const child = $( "#Child" ).val();
		const date = $( "input[name='form[Drop off Date]']" ).val();
 
		if(formId && site && child && date){
			console.log('Form: '+formId+' site: '+site+' child: '+child+' date: '+date);
			$.ajax( {
				// Change the link to the file you are using
				url: 'index.php?option=com_rsform&view=rsform&formId='+formId+'&action=ajax',
				type: 'post',
				// This just sends the value of the dropdown
				data: {
					site: site, child: child, date: date,
				},
				success: function ( response ) {
					// Parse the jSON that is returned
					// Using conditions here would probably apply
					// incase nothing is returned
					var Vals = JSON.parse( response );
					console.log(response);
					console.log(Vals);
					// These are the inputs that will populate
					for (var key in Vals){
						key = key.replace('[]','');
						$("input[name='"+key+"']").each(function() {
							console.log($(this));
							$(this).val(Vals[key]);
						});
						//$( "#"+key ).val(Vals[key]);
						//console.log(`${key} : ${Vals[key]}`)
					}
				}
			} );
		}
 
	}
} );
</script>

Thank you in advance
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!