title: Is it possible to insert a value to a database from a select element and an input tag with the same id?
body: <p>What I'm trying to do is insert value to my database using an id.
  But my problem is i have a <code>&lt;select&gt;</code> and an <code>&lt;input&gt;</code> with the same id and it does not insert any data at all.<br>
  I need to insert the value from #subcat to <code>my_table</code>.<br>
  When #category selected value == "Tuition" i need to use only the <code>&lt;select id="subcat"&gt;</code> and when #category selected value != "Tuition" i need only to use the <code>&lt;input id="subcat"&gt;</code><br>
  I've learned that id should be unique and sorry I am not that good in javascript yet.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>&lt;form method="post" role="form"&gt;
      &lt;label&gt;Category&lt;/label&gt;
      &lt;select id="category"&gt;
          &lt;option value="" hidden&gt;Select Category&lt;/option&gt;
          &lt;option value="Tuition"&gt;Tuition&lt;/option&gt;
          &lt;option value="Miscellaneous"&gt;Miscellaneous&lt;/option&gt;
          &lt;option value="Others"&gt;Others&lt;/option&gt;
      &lt;/select&gt;
      &lt;div id="for_blank"&gt;
          &lt;input type="text" placeholder="Please select a category" readonly&gt;
      &lt;/div&gt;
      &lt;div id="for_tuition" style="display: none;"&gt;
          &lt;select id="subcat"&gt;
              &lt;option value="" hidden&gt;Select subcateogry&lt;/option&gt;
              &lt;option value="Full Payment"&gt;Full Payment&lt;/option&gt;
              &lt;option value="Downpayment"&gt;Downpayment&lt;/option&gt;
          &lt;/select&gt;
      &lt;/div&gt;
      &lt;div id="for_else" style="display: none;"&gt;
          &lt;input type="text" id="subcat" placeholder="Enter Subcategory"
      &lt;/div&gt;
      &lt;script&gt;
          $('#category').change(function() {
              if ($(this).val() == "Tuition") {
                  $('#for_tuition').show();
                  $('#for_blank').hide();
                  $('#for_else').hide();
              } else if ($(this).val() == "Miscellaneous") {
                  $('#for_else).show();
                  $('#for_tuition').hide();
                  $('#for_blank').hide();
              } else if ($(this).val() == "Others") {
                  $('#for_else).show();
                  $('#for_tuition').hide();
                  $('#for_blank').hide();
              } else {
                  $('#for_blank').show();
                  $('#for_tuition').hide();
                  $('#for_else').hide();
              }
          });
      &lt;/script&gt;
      &lt;button type="submit" name="add_item"&gt;Add Record&lt;/button&gt;
  &lt;/form&gt;
  &lt;?php
      if (isset($_POST['add_item'])) {
          $category = $_POST['category'];
          $subcat = $_POST['subcat'];
          $sql = "INSERT INTO my_tbl (category, subcat)
              VALUES ($category, $subcat);";
      }
  ?&gt;
  </code></pre>