<% if (onerec === null) { %>
    <h1>No Record Found</h1>
<% } else { %>
    <h1>Edit Promotion</h1>
    <form action="/promotion/save" method="post">
        <input type="hidden" name="promotion_id" value="<%= onerec.promotion_id %>" >
        <table>
            <tr> <td> Promotion Title: </td> <td> <input type="text" name="promotitle" value="<%= onerec.promotitle %>" required> </td> </tr>
            <tr> <td> Promotion Image: </td> <td> <input type="text" name="promoimage" value="<%= onerec.promoimage %>" required> </td> </tr>
            <tr> <td> Description: </td> <td> <textarea name="description" rows="10" cols="30"><%= onerec.description %></textarea> </td> </tr>
            <tr> <td> Start Date: </td> <td> <input type="date" name="startdate" value=<%= new Date(onerec.startdate).toISOString().split('T')[0] %> required> </td> </tr>
            <tr> <td> End Date: </td> <td> <input type="date" name="enddate" value=<%= new Date(onerec.enddate).toISOString().split('T')[0] %> required> </td> </tr>
            <tr> <td> Discount Rate: </td> <td> <input type="text" name="discountrate" value="<%= onerec.discountrate %>" required> </td> </tr>
        </table>
        <button type="submit">Save</button>
    </form>
<% } %>