How to hide buttons generated by the loop while printing?

@**@
Product Name Exp Date Invoice Number Batch Number Quantity Avl Qty Distributor Name Purchased Date
@if (Model == null) { No Patients } else { @foreach (var item in Model) {
@item.ProductName @item.ExpDate @item.PurchaseBill.InvoiceNumber @item.BatchNumber @Convert.ToInt16(item.Quantity + item.Free).ToString() @(item.AvailableQuantity / item.Package) @item.PurchaseBill.Distributor.DistributorName @Html.Hidden("ProductPurchaseId", @item.ProductPurchaseId) @Html.Hidden("DistributorId", @item.PurchaseBill.DistributorId)
Returning To @Html.DropDownList("DistributorNameDDl", (IEnumerable)ViewBag.DistributorNameDDL, new { @class = "mfpat-drpdwnlist", @style = "width:145px;height:30px" }) @Html.TextArea("ReturnDetails", "", new { @class = "TBReturnDetails", @maxlength = "7500", style = "width: 240px;position:relative;resize:none;height:90px;", @placeholder = "Return Details" })
                    </td>
                </tr>
            }
        </table>

    }
</div>
i have  above div the Return Product buttons are  generated in for loop 
 and i am using below code to print the table but it is only hiding  the first button  restof the buttons are not hidded  why
>  <div onclick=" hidebutton();PrintExpireProducts();" class="nav mf-header-side-label">
     <input type="button" class="mfpat-btn-header" value="Print Expiring Products" id="PrintPurchaseBillBtn" autofocus style="width: 300px; font-weight: bold" />
 </div>

function PrintExpireProducts() {
var divElements = document.getElementById(“ExpryProduct”).innerHTML;
var oldPage = document.body.innerHTML;
document.body.innerHTML =
“” +
divElements + “”;
window.print();
document.body.innerHTML = oldPage;
hidebutton();
}

var display = 0;
function hidebutton() {
var x = document.getElementById(‘HideButton’);

 if (display !=0) {
     x.style.display = "block";
     display = 0;
 } else {
     x.style.display = "none";
     display = 1;
 }

}

In your css add a media rule for print to hide the buttons you dont need when printing

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.