jQuery tokeninput plugin + passing id to another tokeninput url
        Posted  
        
            by 
                Elson Solano
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Elson Solano
        
        
        
        Published on 2012-09-14T05:57:56Z
        Indexed on 
            2012/10/19
            17:01 UTC
        
        
        Read the original article
        Hit count: 286
        
jQuery
|jquery-tokeninput
I am using a jquery plugin called jQuery Tokeninput http://loopj.com/jquery-tokeninput/ and I am having a logic issue.
var country_id = "";
    jQuery("#demo-input-prevent-duplicates").tokenInput(host+"/forms/campaign_location.php?action=country", {
            theme: "facebook",
            hintText: "Enter a Country...",
            placeholder: "Enter a Country...",
            preventDuplicates: true,
            onAdd: function(item) {
                country_id = item.id;
            },
        onDelete: function(){
            hideElements();
        },
        tokenDelimiter: "|",
    });
My question here is how would I pass the value of country_id to the parameter of the below code. I'm not seeing how to do this one on the jquery tokeninput documentation.
jQuery("#targ_state").tokenInput(host+"/forms/campaign_location.php?action=stateorprovince&cid="+country_id, {
        theme: "facebook",
        preventDuplicates: true,
        hintText: "Enter a State or Province...",
        placeholder: "Enter a State or Province..."
    });
If you'll look on this part of the code, I am passing the country_id that was generated above on the "onAdd". This doesn't work though.
jQuery("#targ_state").tokenInput(host+"/forms/campaign_location.php?action=stateorprovince&cid="+country_id ....
How would I do that one? Your help would be greatly appreciated and of course, rewarded!
Thanks! :-)
© Stack Overflow or respective owner