Note that there are some explanatory texts on larger screens.

plurals
  1. POSimple form with jQuery UI dialog and databases
    primarykey
    data
    text
    <p>I'm programming an agenda, and I'd like to open a form within a dialog box (with jQuery UI modal form) and then register the information in my databases but I can't find an exemple of what I wanna do.</p> <p>I've gathered some codes but it doesn't work, I know there are mistakes but I can't correct them as I'm new to jQuery and all that stuff.</p> <p>Here is my code </p> <pre><code>$(function() { $("#dialog").dialog("destroy"); var libelle = $("#libelle"), type = $("#type"), employe = $("#employe"), date = $("#date"), client = $("#client"), camion = $("#camion"), commentaire = $("#commentaire"), allFields = $([]).add(libelle).add(type).add(employe).add(date).add(client).add(camion).add(commentaire); $("#dialog-form").dialog({ autoOpen: false, height: 450, width: 250, modal: false, buttons: { 'Ajouter une tache': function() { $(".ajax").submit( function(e) { var datas = $(this).serialize(); $.ajax({ type: 'POST', url: traitement.php, data: datas, success: function(data) { } }); }); $(this).dialog('close'); }, Retour: function() { $(this).dialog('close'); } }, close: function() { allFields.val('').removeClass('ui-state-error'); } }); $('#create-user') .button() .click(function() { $('#dialog-form').dialog('open'); }); }); </code></pre> <p>and the html</p> <pre><code>&lt;div class="test"&gt; &lt;div id="dialog-form" title="Ajouter une tache"&gt; &lt;form&gt; &lt;fieldset&gt; &lt;label for="libelle"&gt;Libelle&lt;/label&gt; &lt;input type="text" name="libelle" id="libelle" class="text ui-widget-content ui-corner-all" /&gt; &lt;label for="Type"&gt;Type de RDV&lt;/label&gt; &lt;select name="type" id="type" class="text ui-widget-content ui-corner-all" /&gt; &lt;option value="Entretien"&gt;Entretien&lt;/option&gt; &lt;option value="Dépannage"&gt;Dépannage&lt;/option&gt; &lt;option value="Congés"&gt;Congés&lt;/option&gt; &lt;/select&gt; &lt;label for="employe"&gt;Employe&lt;/label&gt; &lt;select name="id_empl" id="id_empl" class="selectbox ui-widget-content ui-corner-all" /&gt; &lt;option value="Entretien"&gt;Entretien&lt;/option&gt; &lt;option value="Dépannage"&gt;Dépannage&lt;/option&gt; &lt;option value="Congés"&gt;Congés&lt;/option&gt; &lt;/select&gt; &lt;label for="date"&gt;Date&lt;/label&gt; &lt;input type="text" name="date" id="date" class="text datepicker ui-widget-content ui-corner-all" /&gt; &lt;label for="client"&gt;Client&lt;/label&gt; &lt;input type="text" name="client" id="client" class="text ui-widget-content ui-corner-all" /&gt; &lt;label for="camion"&gt;Réservation Camion&lt;/label&gt; &lt;input type="checkbox" name="camion" id="camion" class="text ui-widget-content ui-corner-all" /&gt; &lt;label for="commentaire"&gt;Commentaire&lt;/label&gt; &lt;textarea name="commentaire" cols="30" rows="5" class="text ui-widget-content ui-corner-all"&gt;&lt;/textarea&gt; &lt;/fieldset&gt; &lt;/form&gt; &lt;/div&gt; &lt;button id="create-user"&gt;Ajouter une tache&lt;/button&gt; &lt;/div&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload