Search code examples
jquerycakephpfilterhref

Pass value on the one form to get that value in other form in cakephp using jquery and attr href


"Hello Friends, i am newb in web development. bear with my silly question. i checed my requirement but i dint get similar match.

Query - i am working on CRM and i have one form where i am selecting value from dialog box from Account table. There are Contacts under Account . when i am selecting Account i could get the id of the selected account but i dont know how to filter that id with contacts (i have foreign key in contact table id matching in contact). When i click on select contact button dialog box should show only filtered contact which comes under selected account." using this code i get value of selected Account

$('#contact-popup').bind("click", function(){
    var val = $('#OpportunityAccleadId').val();
    $.colorbox({ href:$(this).attr('href')+'/'+val });
    return false;
});

GET localhost/cakeproject/crm1/opportunities/contact_search/6 i got this link, i checked in fire bug . Now how i can use this id 6 to contact_search.ctp file to filter the contact . Can it possible or do i need to work on controller logic.

Account we are selecting at the time of adding data thats why i chosen JS to build.

any help will be helpful for me. Thankx in advance.


Solution

  • Thankx Fazal for your reply. actually i have one add page and on the same page first i select account. and then contact from dialog box. i wanted the contacts from selected account only.

    i got solution on this. i have made changes on below code .

    previous code

    $('#contact-popup').bind("click", function(){
        var val = $('#OpportunityAccleadId').val();
        $.colorbox({ href:$(this).attr('href')+'/'+val });
        return false;
    });
    

    current code - $('#contact-popup').bind("click", function(){ var val = $('#OpportunityAccleadId').val(); $.colorbox({ href:$(this).attr('href')+'/q='+val }); return false; });

    i got hidden ID with the help of this code from add page. then i add condition in contactsearch dialog box page.

    i took value of that id in $_GET['q'] and matched with account id.

    if($variable['model']['id'] == $_GET['q']){
        //add code to display
    }
    

    Thankx fazal.