data['dropdown1'] );?>Inside the ajax event i have a custom codedata['contact2'] as $vals) { $result= "".$vals['name'] . " : ".$vals['address'] . "";echo $result;}$results= json_encode($result);?>I must have forgot some points.How set the dropdown value in the ajax call?How can i display value of the results?Regards"> Display table value from ajax call. - Forums

Forums

Display table value from ajax call.

juansolos 03 Nov, 2016
Hello,
i am looking for an unique contact form.

The dropdown value gives an id. This id is the id of the contact( name address, mail, ...) in the com_contact table.

I try to display contact informations (address tel, etc, ...) depending the dropdown selected option in a container . I try to use ajax for that.

On designer/events, i creat a new event "function call" on (change value) of (dropdown1) function (getcontact()).
On setup, on load, i have a load js with
 
function getcontact()
        {
         var cid = document.getElementById("dropdown1").value;
			jQuery.ajax({
				url: 'mydomaine.com/index.php?option=com_chronoforms5&chronoform=general-contact&event=ajax',
				method: 'get',                    
                success : function(data){
                               document.getElementById('chronoform-container-5').innerHTML = $("results");
                          /*     alert('cid');*/
                               },
                error : function(data){ alert('error');}

			});
		};
          

I get the alert cid so it seems success.

I have created an event called ajax, with a db reader inside with condition
<?php

return array('id' =>$form->data['dropdown1'] );

?>

Inside the ajax event i have a custom code
<div id="coord" style="">
<?php
  foreach ($form->data['contact2'] as $vals) {
        $result= "<div id=coord".$vals['id'].">".$vals['name'] . " : ".$vals['address'] . "</div>";echo $result;}
$results= json_encode($result);
?>
</div>


I must have forgot some points.
How set the dropdown value in the ajax call?
How can i display value of the results?



Regards
juansolos 04 Nov, 2016
1 Likes
Hello,
seems to be solved.
I have done a double drop down (as in faq)
I use a first dropdown with dynamic option from db (get contact name)
I use a second one to get the email from the first one (and use it in dynamic email to). (not id=email but email=email due to the on submit email).

I use this post to display db information depending the first dropdown. (contact address, image, ...).



Regards
This topic is locked and no more replies can be posted.