This commit is contained in:
Aram HARUTYUNYAN 2013-08-01 06:54:17 +00:00
parent 8d46b8cf9c
commit ee0b820a3a

View File

@ -248,10 +248,19 @@ $('div#blocIdLocal').on('click', 'a.addIdLocal', function(e){
e.preventDefault(); e.preventDefault();
var country = $('select[name=adresse_pays]').val(); var country = $('select[name=adresse_pays]').val();
AddSelectCountry(country, $(this).attr('href')); AddSelectCountry(country, $(this).attr('href'));
$('.addIdLocal').hide();
$('.removeIdLocal').hide();
});
$('div#blocIdLocal').on('click', 'a.removeIdLocal', function(e){
e.preventDefault();
var prevId = $(this).attr('href')-1;
$('a#ad'+prevId).show();
$('a#rm'+prevId).show();
$(this).parent().parent().remove();
}); });
function AddSelectCountry(code, n){ function AddSelectCountry(code, n){
if (!n) { n=1; } if (!n) { n=1; } else {n++;}
if (n<=3){ if (n<=3){
var html = 'Aucun identifiant !'; var html = 'Aucun identifiant !';
$.getJSON('/saisie/countryid', {code: code}, function(data){ $.getJSON('/saisie/countryid', {code: code}, function(data){
@ -261,8 +270,10 @@ function AddSelectCountry(code, n){
}); });
if (option!=''){ if (option!=''){
html = '<div class="fieldgrp"><label>Identifiant local</label>'+ html = '<div class="fieldgrp"><label>Identifiant local</label>'+
'<div class="field"><input type="text" name="idLoc'+n+'Num"/>'+ '<div class="field"><input size="35" type="text" name="idLoc'+n+'Num"/>'+
'<select name="idLoc'+n+'Type">'+option+'</select><a href="'+n+'" class="addIdLocal">[+]</a></div></div>'; '<select name="idLoc'+n+'Type">'+option+'</select>';
if (n<3) { html = html+'<a href="'+n+'" class="addIdLocal" id="ad'+n+'">[+]</a>';}
html = html+'<a href="'+n+'" class="removeIdLocal" id="rm'+n+'">[-]</a></div></div>';
} }
$('div#blocIdLocal').append(html); $('div#blocIdLocal').append(html);
}); });