summaryrefslogtreecommitdiff
path: root/public/libs/steps.js
blob: be7cc6b7ec4588ea0581bb1a9b189a2c0c012991 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
$('#plus').on('click', (event) => {
    const newVal = parseInt(document.querySelector('#stpnum').value) + 1;
    document.querySelector('#stpnum').value = newVal;
    const step = newVal;
    $('#sub').before(`
        <label id='added${step}' for="">Step Number:</label>
        <input id='added${step}' name='step${step}[number]' type='text' value='${step}'>
        <label id='added${step}' for="">Step photo:</label>
        <input id='added${step}' name='step${step}[photo]' type="text">
        <label id='added${step}' for="">Step instructions:</label>
        <input id='added${step}' name='step${step}[step]' type="text">
    `)
});

$('#minus').on('click', (event) => {
    const newVal = parseInt(document.querySelector('#stpnum').value) - 1;
    document.querySelector('#stpnum').value = newVal;
    const step = newVal;
    const toRm = step + 1;
    for(i = 0; i < 6; i++) {
        $(`#added${toRm}`).remove();
    }
});