如何不执行隐藏的表单

<script> 
$(document).ready(function(){
  $("#hdcChoose").click(function(){
    $("#hdcNumber").toggle();
    $("#hdcNumber2").hide();
  });
});
$(document).ready(function(){
  $("#hdcWrite").click(function(){
    $("#hdcNumber").hide();
    $("#hdcNumber2").toggle();
  });
});
</script>

"hdcWrite" and "hdcChoose" are my fields that the user can show or hide. Both consist of a Number that is needed for my SQL query. Here are my SQL WHERE statments:

WHERE HDC.NAME ='$hdcChoose'
OR HDC.NAME = '$hdcWrite'");

The problem is, that when first field is hidden,and it's not null, it's executed as first in my SQL Query. any idea how can I avoid that? Is there any usefull function for that?

The best solution is to set the wanted values as "" when the form is clicked. It's very simple:

$("#hdcNumber").val("");

You can add an <input type="hidden" id="hdc"> which is filled by the good value when the user click on "hdcWrite" or "hdcChoose" and SQL works with this value.

I thought something like this:

<input type="hidden" id="hdc">
<script> 
$(document).ready(function(){
  $("#hdcChoose").click(function(){
    $("#hdcNumber").toggle();
    $("#hdcNumber2").hide();
    $("#hdc").val($("#hdcNumber").val()); // or $("#hdc").val("hdcNumber");
  });
});
$(document).ready(function(){
  $("#hdcWrite").click(function(){
    $("#hdcNumber").hide();
    $("#hdcNumber2").toggle();
    $("#hdc").val($("#hdcNumber2").val()); // or $("#hdc").val("hdcNumber2");
  });
});
</script>

and SQL would recover the value of the "hdc" like something that:

WHERE HDC.NAME ='$hdc'

You can check onsubmit if the field is hidden and empty the value:

if($('#hdcChoose').css('display') == 'none')) {
   $('#hdcChoose').val("");
}