75 lines
2.0 KiB
PHTML
75 lines
2.0 KiB
PHTML
<div class="fieldgrp">
|
|
<label>Pays</label>
|
|
<div class="field">
|
|
<select name="adresse_pays">
|
|
<option value="">-</option>
|
|
<?php foreach($this->countries as $code => $lib) {?>
|
|
<option value="<?=$code?>"><?=$lib?></option>
|
|
<?php }?>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="blocIdLocal"></div>
|
|
|
|
<div class="fieldgrp">
|
|
<label>Adresse</label>
|
|
<div class="field">
|
|
<input type="text" name="adresse_num" size="4"/>
|
|
<input type="text" name="adresse_btq" size="1"/>
|
|
<input type="text" name="adresse_codvoie" size="4"/>
|
|
<input type="text" name="adresse_libvoie" size="32"/>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="fieldgrp">
|
|
<label>Adresse complément</label>
|
|
<div class="field">
|
|
<input type="text" name="adresse_comp" size="40"/>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="fieldgrp">
|
|
<label>CP</label>
|
|
<div class="field">
|
|
<input type="text" name="adresse_cp"/>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="fieldgrp">
|
|
<label>Ville</label>
|
|
<div class="field">
|
|
<input type="text" name="adresse_ville"/>
|
|
</div>
|
|
</div>
|
|
<script>
|
|
$('select[name=adresse_pays]').change(function(e){
|
|
$('div#blocIdLocal').html('');
|
|
AddSelectCountry($(this).val());
|
|
});
|
|
|
|
$('div#blocIdLocal').on('click', 'a.addIdLocal', function(e){
|
|
e.preventDefault();
|
|
var country = $('select[name=adresse_pays]').val();
|
|
AddSelectCountry(country, $(this).attr('href'));
|
|
});
|
|
|
|
function AddSelectCountry(code, n){
|
|
if (!n) { n=1; }
|
|
if (n<=3){
|
|
var html = '';
|
|
$.getJSON('/saisie/countryid', {code: code}, function(data){
|
|
var option = '';
|
|
$.each(data, function(i, item){
|
|
option = option + '<option value="'+item.internalId+'">'+item.name+'</option>';
|
|
});
|
|
if (option!=''){
|
|
html = '<div class="fieldgrp"><label>Identifiant local</label>'+
|
|
'<div class="field"><input type="text" name="idLoc'+n+'Num"/>'+
|
|
'<select name="idLoc'+n+'Type">'+option+'</select><a href="'+n+'" class="addIdLocal">[+]</a></div></div>';
|
|
}
|
|
$('div#blocIdLocal').append(html);
|
|
});
|
|
}
|
|
}
|
|
</script>
|