title: Jquery validate and submit more forms on one page
body: <p>So I am dealing with some survey pages. First my makesurvey.php reads all questions and then create page for editing questions and creating new questions. Each question is in own form and it has own submit. Then admin of survey can on page makessurvey.php fix the existing questions and also can add new question which is subbmited to handlesurvey.php wich makes updates to database.  That means on one page I have let's say 20 forms with submit button. Now I realise that I have encountered more problems. The survey will be handle only by one admin. And this survey apllication needs to work dynamic, because admin can enter some new question, later can delete some questions. After some time add new questions, then delete and so on. </p>
  
  <p>PROBLEMS: </p>
  
  <p>1.Problem: On page makesurvey when admin wants to edit survey how to make just one jQuery function, which will first validate then submmit form to handlesurvey.php. (admin will edit one question at time and press submit). The other option is to generate so many js functions for each form but I think that isn't appropriaty way, but I think it would work fine.
  2.Problem: When admin adds/edits some question how should my handlesurvey.php know which variable is in <code>$_POST[&lt;some_variable&gt;]</code>.</p>
  
  <p>Generated makesurvey.php page:</p>
  
  <pre><code> &lt;script type="text/javascript"&gt;
   $("form#updateQuestion").submit(function(){
  var SloQuestion = $("#SloQuestion").val();
  var typeQuestion=$('#typeQuestion').val();
  var RadioValue1=$('#RadioValue1').val();
  var RadioValue2=$('#RadioValue2').val();
  var RadioValue3=$('#RadioValue3').val();
  var RadioValue4=$('#RadioValue4').val();    
  
  //HERE I WILL DO SOME VALIDATION
  
  /*  $.post( "editSurveyHandle.php", $("form#updateQuestion").serialize())
            .done(function( data ) {
            alert("You have changed question!");
     /*     });
         return false;*/
   });      
  
   &lt;/script&gt;
   &lt;/head&gt;
   &lt;html&gt;
   &lt;body&gt;
   &lt;form id='updateQuestion1' name='updateQuestion1' method='post' action=''&gt;
   &lt;input type='hidden' name='hidden' value='question1'/&gt;&lt;table width='600px'&gt;&lt;tr&gt;&lt;/tr&gt;
   &lt;tr&gt;&lt;td width='50%' valign='top'&gt;&lt;label for='question1'&gt;&lt;h2&gt;CURRENT QUESTION:          &lt;/h2&gt;&lt;/label&gt;&lt;/td&gt;&lt;/tr&gt;
   &lt;tr&gt;&lt;td&gt;SLOVENIAN &lt;/td&gt;&lt;td width='50%' valign='top'&gt; &lt;label for='question1'&gt;Some question 1 *&lt;/label&gt;&lt;/td&gt;&lt;/tr&gt;
   &lt;tr&gt;&lt;td width='50%' valign='top'&gt;TYPE QUESTION&lt;/td&gt;&lt;td width='50%' valign='top'&gt;RADIO BUTTON&lt;/td&gt;&lt;/tr&gt;
   &lt;tr&gt;&lt;td&gt;&lt;h4&gt;DELETE QUESTION&lt;/h4&gt;&lt;/td&gt;&lt;td&gt;&lt;input type='checkbox' id='deleteQuestion' name='deleteQuestion' value='delete'/&gt;&lt;/td&gt;&lt;/tr&gt;
   &lt;tr&gt;&lt;td&gt;&lt;h4&gt;CHANGE QUESTIOn&lt;/h4&gt;&lt;/td&gt;&lt;/tr&gt;
   &lt;tr&gt;&lt;td&gt;&lt;label&gt;SLOVENIAN&lt;/label&gt;&lt;/td&gt;&lt;td&gt;&lt;input type='text' id='SloQuestion' name='SloQuestion' size='50' value ='Velikost sobe *'&gt;&lt;/td&gt;&lt;/tr&gt;
   &lt;tr&gt;&lt;td&gt;TYPE QUESTION &lt;/td&gt;&lt;td&gt;&lt;select id='typeQuestion' name='typeQuestion'&gt;
   &lt;option value='text'&gt;Malo vnosno polje&lt;/option&gt;
   &lt;option value='textarea'&gt;Textarea&lt;/option&gt;
   &lt;option selected='selected' value='radio'&gt;Izbirino polje&lt;/option&gt;
   &lt;/select&gt;&lt;/tr&gt;
   &lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;input type='text' id='RadioValue0' name='RadioValue10' size='50' value ='Bad'&gt;&lt;/td&gt;&lt;/tr&gt;
   &lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;input type='text' id='RadioValue1' name='RadioValue11' size='50' value ='Sufficiently'&gt;&lt;/td&gt;&lt;/tr&gt;
   &lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;input type='text' id='RadioValue2' name='RadioValue12' size='50' value ='Dobro'&gt;&lt;/td&gt;&lt;/tr&gt;
   &lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;input type='text' id='RadioValue3' name='RadioValue13' size='50' value ='Excelent'&gt;&lt;/td&gt;&lt;/tr&gt;
   &lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;input type ='submit' id='submit' name='submit' value='Izvedi spremembe'/&gt;&lt;/td&gt;&lt;/tr&gt;     
   &lt;/table&gt;
   &lt;/form&gt; 
  
   &lt;form id='updateQuestion2' name='updateQuestion2' method='post' action=''&gt;
   &lt;input type='hidden' name='hidden' value='question2'/&gt;&lt;table width='600px'&gt;&lt;tr&gt;&lt;/tr&gt;
   &lt;tr&gt;&lt;td width='50%' valign='top'&gt;&lt;label for='question2'&gt;&lt;h2&gt;CURRENT QUESTION:&lt;/h2&gt;&lt;/label&gt;&lt;/td&gt;&lt;/tr&gt;
   &lt;tr&gt;&lt;td&gt;SLOVENIAN &lt;/td&gt;&lt;td width='50%' valign='top'&gt; &lt;label for='question2'&gt;Some question 2&lt;/label&gt;&lt;/td&gt;&lt;/tr&gt;
   &lt;tr&gt;&lt;td width='50%' valign='top'&gt;TYPE QUESTION&lt;/td&gt;&lt;td width='50%' valign='top'&gt;RADIO BUTTON&lt;/td&gt;&lt;/tr&gt;
   &lt;tr&gt;&lt;td&gt;&lt;h4&gt;DELETE QUESTION&lt;/h4&gt;&lt;/td&gt;&lt;td&gt;&lt;input type='checkbox' id='deleteQuestion' name='deleteQuestion' value='delete'/&gt;&lt;/td&gt;&lt;/tr&gt;
   &lt;tr&gt;&lt;td&gt;&lt;h4&gt;CHANGE QUESTIOn&lt;/h4&gt;&lt;/td&gt;&lt;/tr&gt;
   &lt;tr&gt;&lt;td&gt;&lt;label&gt;SLOVENIAN&lt;/label&gt;&lt;/td&gt;
   &lt;td&gt;&lt;input type='text' id='SloQuestion' name='SloQuestion' size='50' value ='Some question 2'&gt;&lt;/td&gt;&lt;/tr&gt;
   &lt;tr&gt;&lt;td&gt;TYPE QUESTION &lt;/td&gt;&lt;td&gt;&lt;select id='typeQuestion' name='typeQuestion'&gt;&lt;option value='text'&gt;Text field&lt;/option&gt;
   &lt;option value='textarea'&gt;Textarea&lt;/option&gt;&lt;option selected='selected' value='radio'&gt;Radio&lt;/option&gt;&lt;/select&gt;&lt;/tr&gt;
   &lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;input type='text' id='RadioValue0' name='RadioValue10' size='50' value ='Bad'&gt;&lt;/td&gt;&lt;/tr&gt;
   &lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;input type='text' id='RadioValue1' name='RadioValue11' size='50' value ='Sufficiently'&gt;&lt;/td&gt;&lt;/tr&gt;
   &lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;input type='text' id='RadioValue2' name='RadioValue12' size='50' value ='Dobro'&gt;&lt;/td&gt;&lt;/tr&gt;
   &lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;input type='text' id='RadioValue3' name='RadioValue13' size='50' value ='Excelent'&gt;&lt;/td&gt;&lt;/tr&gt;
   &lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;input type ='submit' id='submit' name='submit' value='Izvedi spremembe'/&gt;&lt;/td&gt;&lt;/tr&gt;
   &lt;/table&gt;
   &lt;/form&gt; 
  </code></pre>
  
  <p>Still editSurvey.php page (I have add two because I can't put all text just in one textarea)</p>
  
  <pre><code> &lt;form id='updateQuestion3' name='updateQuestion3' method='post' action=''&gt;
   &lt;input type='hidden' name='hidden' value='question3'/&gt;
   &lt;table width='600px'&gt;&lt;tr&gt;&lt;/tr&gt;
   &lt;tr&gt;&lt;td width='50%' valign='top'&gt;&lt;label for='question3'&gt;&lt;h2&gt;CURRENT QUESTION:&lt;/h2&gt;&lt;/label&gt;&lt;/td&gt;&lt;/tr&gt;
   &lt;tr&gt;&lt;td&gt;SLOVENIAN &lt;/td&gt;&lt;td width='50%' valign='top'&gt; &lt;label for='question3'&gt;Some question 3&lt;/label&gt;&lt;/td&gt;&lt;/tr&gt;
   &lt;tr&gt;&lt;td width='50%' valign='top'&gt;TYPE QUESTION&lt;/td&gt;&lt;td width='50%' valign='top'&gt;RADIO BUTTON&lt;/td&gt;&lt;/tr&gt;
   &lt;tr&gt;&lt;td&gt;&lt;h4&gt;DELETE QUESTION&lt;/h4&gt;&lt;/td&gt;&lt;td&gt;&lt;input type='checkbox' id='deleteQuestion' name='deleteQuestion' value='delete'/&gt;&lt;/td&gt;&lt;/tr&gt;
   &lt;tr&gt;&lt;td&gt;&lt;h4&gt;CHANGE QUESTIOn&lt;/h4&gt;&lt;/td&gt;&lt;/tr&gt;
   &lt;tr&gt;&lt;td&gt;&lt;label&gt;SLOVENIAN&lt;/label&gt;&lt;/td&gt;&lt;td&gt;&lt;input type='text' id='SloQuestion' name='SloQuestion' size='50' value ='Some question 3'&gt;&lt;/td&gt;&lt;/tr&gt;
   &lt;tr&gt;&lt;td&gt;TYPE QUESTION &lt;/td&gt;&lt;td&gt;&lt;select id='typeQuestion' name='typeQuestion'&gt;&lt;option value='text'&gt;Textfield&lt;/option&gt;
  </code></pre>
  
  <p>TextareaRadio
       
       
       
       
       
       
        
       
  </p>
  
  <p>And my handlesurvey.php file:</p>
  
  <pre><code> if(isset($_POST["hiddenUpdateQuestion"])){
  $username = 'root';
  $password='';
  $hostname='localhost';
  $dbhandle = mysql_connect($hostname, $username, $password)
  or die("Ni se mogoče povezati na MySQL");
  $selcetedDB = mysql_select_db("amon_survey",$dbhandle);
  mysql_query("set names 'utf8'");
  
  // HERE I WILL ENTER LATER SOME QUERY 
  mysql_close($dbhandle);
   }
  </code></pre>