[support] something about drupal and jquery

Aldo Martinez Selleras aldo at caonao.cu
Mon Nov 2 15:25:18 UTC 2009


hello all, i'm doing a little form for add links in my site, for a 
adminstration module, with custom links for each user, well, i'm using 
jquery for this, this is my form

$cats = bmg_categories(NULL);
$content .= '<fieldset class="bmg-fieldset right-side" id="customlinks">';
$content .= '<legend><i>Custom Links</i></legend>';
$content .= '<form name="addLink" action="#">';
$content .= 'Title: <input type="text" size="35" id="titleLink"><br>';
$content .= 'Path: <input type="text" size="35" id="pathLink"><br>';
$content .= '<input type="hidden" value="'.arg(1).'" id="boardId">';
$content .= 'Category: <select id="catsLink">';
	foreach ( $cats as $key => $value) {
		$content .= '<option value="'.$key.'">'.$value.'</option>';
	}
$content .= '</select>';
$content .= '<input type="button" value="Add Link" 
onclick="bmg_addLink()">';
$content .= '</form>';
$content .= '<div id="listCustomLinks"></div>';
$content .= '</fieldset>';

and my javascript function is this:

function bmg_addLink(obj) {
var path = $('#pathLink').attr('value');
var regex = /[\/]+/g;
var newPath = path.replace( regex , "-");
$.get(document.URL.split("=")[0] + '=' + 'addLinks/' + 
$('#titleLink').attr('value') + '/' + newPath + '/' + 
$('#boardId').attr('value') + '/' + $('#catsLink').attr('value'), null, 
function(d) {
$('#titleLink').attr('value', '');
$('#pathLink').attr('value', '');
$('#catsLink').attr('value', '1');
});
alert("The Link has been Added");
}

so, i need when the javascript function end, them i need to execute a 
php function for show in:

$content .= '<div id="listCustomLinks"></div>';

and, this without the page refresh!


thks in advanced


More information about the support mailing list