1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
| <script>
$(function() {
// a workaround for a flaw in the demo system (http://dev.jqueryui.com/ticket/4375), ignore!
$( "#dialog:ui-dialog" ).dialog( "destroy" );
var mot_cle = $( "#mot_cle" ),
url_destination = $( "#url_destination" ),
name = $( "#name" ),
url = $( "#url" ),
id_client = "<?php echo $_SESSION["id_client"]; ?>",
allFields = $( [] ).add( mot_cle ).add( url_destination ).add( name ).add( url ).add( id_client );
function updateTips( t ) {
tips
.text( t )
.addClass( "ui-state-highlight" );
setTimeout(function() {
tips.removeClass( "ui-state-highlight", 1500 );
}, 500 );
}
function checkLength( o, n, min, max ) {
if ( o.val().length > max || o.val().length < min ) {
o.addClass( "ui-state-error" );
updateTips( "Length of " + n + " must be between " +
min + " and " + max + "." );
return false;
} else {
return true;
}
}
function checkRegexp( o, regexp, n ) {
if ( !( regexp.test( o.val() ) ) ) {
o.addClass( "ui-state-error" );
updateTips( n );
return false;
} else {
return true;
}
}
$( "#dialog-form" ).dialog({
autoOpen: false,
height: 300,
width: 350,
modal: true,
buttons: {
"Ajouter": function() {
var bValid = true;
allFields.removeClass( "ui-state-error" );
// appel du fichier php pour insertion de données
$.ajax({
type: "POST",
url: "ajout_mot_cle.php",
data: "mot_cle="+mot_cle.val()+"&url_destination="+url_destination.val()+"&name_site="+name.val()+"&url_site="+url.val()+"&id_client="+id_client,
success: function(msg){
$("#id_assoc").append("test "+ msg);
alert(msg);
}
});
$( this ).dialog( "close" );
},
Cancel: function() {
$( this ).dialog( "close" );
}
},
close: function() {
allFields.val( "" ).removeClass( "ui-state-error" );
}
});
$( "#create-user" ).click(function() {
$( "#dialog-form" ).dialog( "open" );
});
});
</script> |
Partager