User Tools

Site Tools


Populate <select> from JSON with jQuery

Using a returned JSON like this:

$('#parentSelectId').change(function {
    $.getJSON('', function (data) {
        var select = $('#childrenSelectId');
        var options = select.prop ? select.prop('options') : select.attr('options') ;
        $('option:not(:first)', select).remove();
        $.each(data, function (index, array) {
            options[options.length] = new Option(,;
User script: Add facebook tab on a facebook page

Call this from any facebook app page. The secure page url must be set.

// ==UserScript==
// @name           Facebook Add Page Tab
// @description    Insert a link to add a page tab on facebook
// @namespace      dan
// @include        htt*://**
// @match*
// @exclude        htt*://*channel**
// @exclude        htt*://*static**
// @exclude        htt*://*
// @exclude        htt*://**
// ==/UserScript==
var appId = location.pathname.split('/')[2];
var appUrl = document.getElementById('secure_page_tab_url').value;
var headMenu = document.getElementById('headerArea');
var link = document.createElement('a');
link.setAttribute('href', '' + appId + '&next=' + appUrl);
link.setAttribute('target', '_blank');
link.appendChild(document.createTextNode('Agregar Tab'));


javascript:(function(){var appId=location.pathname.split('/')[2];var appUrl=document.getElementById('secure_page_tab_url').value;var headMenu=document.getElementById('headerArea');if(appUrl==''){alert('Debes llenar el campo de "URL segura de la pesta%C3%B1a"');return false;}var link=document.createElement('a');link.setAttribute('href',''+appId+'&next='+appUrl);link.setAttribute('target','_blank');link.appendChild(document.createTextNode('Agregar Tab a Pagina'));headMenu.appendChild(link);})();
snippets/javascript.txt · Last modified: 2015/12/11 17:16 by osiux