未隐藏的表单

时间:2017-04-08 09:03:49

标签: javascript jquery

我正在尝试创建一个能够获取数据并显示它的表,并且它运行良好。但是,我在这个表中有一行应该被隐藏,只有在按下按钮后才会显示,但它不会被隐藏。我做错了什么?

<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>

1 个答案:

答案 0 :(得分:1)

看起来,问题就在你的风格中。

modificato<?php echo $id;?>

将寻找一个元素modificato(例如,modificato123)。

但是,据我所知,你需要隐藏一个表格。然后你的风格看起来像

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

或者:

.form {
    display: none;
}

或者:

#some-element-id {
    display: none;
}
相关问题