Button Element in repeat-group example to run php using ajax and jquery

Status
Not open for further replies.

rtrauer

Member
Hi,
I need to run a php code when a button element is clicked.
It is inside a repeat group.
Using joomla 3.5.6, Fabrik 3,5,2, and template is Helix3 from JoomShaper.com
So, I?m using template overrides to make Fabrik work great on this template.

I followed /components/com_fabrik/user_ajax_example.php
But javascript examples that I found use Mootools Ajax class and is giving errors for me.

I customized the php file, and this is giving me the html return that I need.

I need help with the javascript code to place in button element that should be triggered by onClick event.
So far, the javascript code looks like this
JavaScript:
var repeat = this.getRepeatNum();
var userid = this.form.formElements.get('jm35_fb_cond_home_26_repeat___user_id_' + repeat).getValue();  
var phonetype = this.form.formElements.get('jm35_fb_cond_home_26_repeat___phone_type_' + repeat).getValue(); 
var homeid = this.form.formElements.get('jm35_fb_cond_home_26_repeat___parent_id_' + repeat).getValue(); 
 console.log('UserID =' + userid);
 console.log('repeat =' + repeat);
 console.log('PhoneType =' + phonetype);
 console.log('Home =' + homeid);

var url =  'index.php?option=com_fabrik&format=raw&task=plugin.userAjax&method=callPhone&u=';
url = url + userid + '&h=' + homeid + '&t=' + phonetype;
new Ajax(url, {
   onComplete: function(response) {
     if (response !== '') {
        alert(response);
        refocus.value = '';
        refocus.focus();
     }
    }
  }
).request();

Thanks for any help.
 
JavaScript:
callPhone(userid,homeid,phonetype);

function callPhone(userid,homeid,phonetype){
    var url = 'index.php?option=com_fabrik&format=raw&task=plugin.userAjax&method=callPhone&u=' + userid + '&h=' + homeid + '&t=' + phonetype;
    new Request({
        url: url,
        onComplete:function(r){
            var result = jQuery.parseJSON(r);
            console.log('result', result);
        }
    }).send();
}
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top