title: How can i call a function that executes an fpdf based on the choice of a form selector?
body: <p>I am trying to create FPDF's with different formats, which are inside a file of functions that are called through a form on another page inside the field selector = muni, but it is not respecting me the if and always takes the first function, could you guide me?</p>
  <p>This is the form</p>
  <pre><code>&lt;form id=&quot;clientForm&quot; name=&quot;formularioDatos&quot; method=&quot;post&quot; action=&quot;insertBD.php&quot;  target=&quot;print_popup&quot; 
    onsubmit=&quot;window.open('about:blank','print_popup','width=1000,height=800');&quot;&gt;
  
  &lt;div class= col-md-3&gt;
      &lt;select class=&quot;form-control input-lg&quot; id=&quot;idMunicipio&quot; name=&quot;idMunicipio&quot; #&gt;
          &lt;option value=&quot;&quot; #&gt;MUNICIPIO&lt;/option&gt;
          &lt;option value=&quot;ACOLMAN&quot;&gt;ACOLMAN&lt;/option&gt;
          &lt;option value=&quot;ZUMPANGO&quot;&gt;ZUMPANGO&lt;/option&gt;
      &lt;/select&gt;
      &lt;input id=&quot;muni&quot; name=&quot;muni&quot; hidden=&quot;true&quot;&gt;
  &lt;/div&gt;
  </code></pre>
  
  
  
  <pre><code>&lt;script&gt;
      $(&quot;#idMunicipio&quot;).change(function () {
      // aqui vuelve a colocar el id de tu select, pero en esta ocación detectamos el valor que tiene el mismo
      $(&quot;#idMunicipio option:selected&quot;).each(function () {
          // luego guardas el valor en una variable
          var muni = $(this).val();
          $(&quot;#muni&quot;).val(muni);
      });
  });
  &lt;/script&gt;
  </code></pre>
  <p>This is de insertion in db:</p>
  <pre><code>&lt;?php 
  
  include (&quot;pdffunctions.php&quot;);
  include(&quot;conn.php&quot;);
  $con = connect();
  $muni = mysqli_real_escape_string($con, $_POST['muni']);
  $way_pay = mysqli_real_escape_string($con,$_POST['way_pay']);
  $amount = mysqli_real_escape_string($con,$_POST['amount']);
  $concept = mysqli_real_escape_string($con,$_POST['concept']);
  $file_name = date(&quot;Y-m-d&quot;) . &quot;_&quot;. $rfc.&quot;.pdf&quot;;
  
  $sql = &quot;INSERT INTO naucalpan(muni, way_pay, amount, concept, )VALUES('$muni', '$way_pay', '$amount', '$concept', )&quot;;
  $query= mysqli_query($con, $sql);
  if ($muni == 'NAUCALPAN' OR 'HUIXQUILUCAN' )
  {
      nau($muni, $way_pay, $concept, $file_name);
  }
  elseif($muni == 'ACOLMAN' OR 'ATENCO' OR 'AXAPUSCO' OR 'CHIAUTLA' OR 'CHICOLOAPAN' OR 'CHICONCUAC' OR 'CHIMALHUACAN' OR 'NOPALTEPEC' OR 'OTUMBA' OR 'PAPALOTLA' OR 'LA PAZ' OR 'SAN MARTIN DE LAS PIRAMIDES' OR 'TEOTIHUACAN' OR 'TEPETLAOXTOC' OR 'TEXCOCO' OR 'TEZOYUCA')
  {
      tex( $muni, $way_pay, $concept, $file_name);
  }
  </code></pre>
  <p>And here my functions in pdffunctions.php</p>
  <pre><code>&lt;?php
      require('fpdf/fpdf.php');
      class PDF extends FPDF
      {}
  
      function nau( $muni, $way_pay, $concept, $file_name){
          
          $pdf = new FPDF();
          $pdf-&gt;AddPage();
          $pdf-&gt;SetTextColor(56,56,56);
          $pdf-&gt;SetFont('Arial','B',7);
          $pdf-&gt;SetMargins(10,10,10,10);
          $pdf-&gt;SetY(53);
          $pdf-&gt;Setx(45);
          $pdf-&gt;Cell(45,12,utf8_decode(''.$muni),0, 0, 'L');
          $pdf-&gt;Ln();
          $pdf-&gt;Setx(45);
          $pdf-&gt;Cell(45,12,utf8_decode(''. $way_pay),0, 0, 'L');
          $pdf-&gt;SetY(56);
          $pdf-&gt;Setx(108);
          $pdf-&gt;MultiCell(60, 12, utf8_decode(''. $concept.&quot;    TLANEPANTLA&quot;),0, 0, 'L');
          $pdf-&gt;Ln();
  
          $pdf-&gt;Output('F', &quot;pdfs/$file_name&quot;);
          $pdf-&gt;Output();
      };
  
      function tex($muni, $way_pay, $concept, $file_name){
          
          $pdf = new FPDF();
          $pdf-&gt;AddPage();
          $pdf-&gt;SetTextColor(56,56,56);
          $pdf-&gt;SetFont('Arial','B',7);
          $pdf-&gt;SetMargins(10,10,10,10);
          $pdf-&gt;SetY(53);
          $pdf-&gt;Setx(45);
          $pdf-&gt;Cell(45,12,utf8_decode(''.$muni),0, 0, 'L');
          $pdf-&gt;Ln();
          $pdf-&gt;Setx(45);
          $pdf-&gt;Cell(45,12,utf8_decode(''. $way_pay),0, 0, 'L');
          $pdf-&gt;SetY(56);
          $pdf-&gt;Setx(108);
          $pdf-&gt;MultiCell(60, 4, utf8_decode(''. $concept.&quot;TEXCOCO&quot;),0, 0, 'L');
          
              $pdf-&gt;Output('F', &quot;pdfs/$file_name&quot;);
              $pdf-&gt;Output();
          }
  ?&gt;
  </code></pre>