Ken Invernici
Ken Invernici

Reputation: 25

Form that is not hiding

I'm trying to do a table that takes data and displays it, and it works pretty well. However, I have a row in this table that should be hidden and should only be displayed after I press a button, but it is not hidden. What am I doing wrong?

<style>
    modificato<?php echo $id;?>{
        display: none;
    }
</style>

<script>
    function modificato<?php echo $id;?> {
        document.querySelector("modificato<?php echo $id;?>").style.display = "block";
    }
</script>

<form name="modificato<?php echo $id?>" class="form" method="post" action="" style="display: none;">
    <tr>
        <th>PREMI PER</th>
        <th><input type="submit" name="bottone_modificato<?php echo $id;?>" value="CONFERMARE"></th>
        <th><input type="date" name="data<?php echo $id;?>" value='<?php echo $data?>'></th>
        <th><input type="text" name="nome<?php echo $id;?>" size="10" maxlength="<?php echo $LENGTH_NOME;?>" value="<?php echo $nome;?>"></th>
        <th><input type="text" name="valore<?php echo $id;?>" onkeypress='return event.charCode >= 46 && event.charCode <= 57' size="6" maxlength="<?php echo $LENGTH_PREZZO;?>" value="<?php echo $valore;?>"></th>
        <th><input type="text" name="chilometri<?php echo $id;?>" onkeypress='return event.charCode >= 46 && event.charCode <= 57' size="6" maxlength="<?php echo $LENGTH_CHILOMETRI;?>" value="<?php echo $chilometri;?>"></th>
        <th><textarea name="note<?php echo $id;?>" rows="3" cols="20" maxlength="250"><?php echo $note;?></textarea></th>
    </tr>
</form>

Upvotes: 0

Views: 30

Answers (1)

ghostprgmr
ghostprgmr

Reputation: 488

Looks, like problem is in your styles.

modificato<?php echo $id;?>

will look for an element modificato (for example, modificato123).

But, as I understand, you need to hide a form. Then your style can look like

form[name=modificato<?php echo $id;?>] {
    display: none;
}

Or:

.form {
    display: none;
}

Or:

#some-element-id {
    display: none;
}

Upvotes: 1

Related Questions