<script language="javascript" type="text/javascript">
function validate()
{
	if(document.formRepeated.idCategory.value == '0')
	{
		alert('<?php echo $numberLBL["selectCategory"];?>');
		document.formRepeated.idCategory.focus();
		return false;
	}
	else
	{
		return true;	
	}
}
</script>
<form name="formRepeated" method="post" action="searchRepeatedCategory.php" onsubmit="return validate()">
<div class="modal fade modal-fullscreen " style="z-index:10000;padding-<?php echo $align;?>:0px" id="searchRepeatedModal" tabindex="-1" role="dialog" aria-labelledby="searchRepeatedModalTitle" aria-hidden="true">
  <div class="modal-dialog modal-dialog-centered" role="document">
     <div class="modal-content text-right">
        <div class="modal-header modal-header-primary">
           <h5 class="modal-title" id="searchRepeatedModalTitle"><?php echo $button["repeatedNum"];?></h5>
           <button type="button" class="close slidedown" data-dismiss="modal" aria-label="Close">
           <span aria-hidden="true">&times;</span>
           </button>
        </div>
        <div class="modal-body" style="text-align: <?php echo $align;?>;">
           <div class="form-group" style="margin-bottom: 0px;">
              <label for="idCategorySer2" class="col-form-label myModalLabel"> <?php echo $numberLBL["category"];?>:</label>
              <select name="idCategory" id="idCategorySer2"  class="form-control" style="padding:0px">
              <option value="0"><?php echo $numberLBL["select"];?></option>
                  <?php
					$queryCategory  = "select id,name from ".$userCategory." where userId='".$_SESSION["userId"]."' ";
					$resultCategory = mysqli_query($conn, $queryCategory);
					$numCategory = mysqli_num_rows($resultCategory);
					for($c=0;$c<$numCategory;$c++)
					{
						$rowCategory= mysqli_fetch_row($resultCategory);?>
						<option value='<?php echo $rowCategory[0];?>' ><?php echo $rowCategory[1]?></option>
						<?php
					}
				?>
              </select>
           </div>
           
           <div class="form-group" style="margin-bottom: 0px;">
              <label for="subCateSer2" class="col-form-label myModalLabel"> <?php echo $numberLBL["subCategory"];?>:</label>
              <select id="subCateSer2" name="subCateSer" class="form-control" style="padding:0px">
              </select>
           </div>
           
        </div>
        <div class="modal-footer">
           <button type="button" class="btn bg-danger btn-flat text-white m-1" data-dismiss="modal"><?php echo $button["close"];?></button>
           <input type="submit" value='<?php echo $button["search"];?>' name="sub" class="btn bg-primary btn-flat text-white m-1">
        </div>
     </div>
  </div>
</div>

</form>
<script type="text/javascript">
	$(document).ready(function(){
		$("#idCategorySer2").change(function (){
			$.post("fetchSubCategory.php",{ id:$("#idCategorySer2").val(),rand:Math.random() } ,function(res){
			$("#subCateSer2").html(res);
			});
		});
	});
</script>  
