显示基于javascript函数结果的HTML代码


Display HTML code based on the result of javascript function

我有一个带有文本字段的表单,如下所示:-

    <form name = "myform" id="div" method = "POST" enctype="multipart/form-data" action = "action.php" onsubmit = "return ValidationTest()">
<textarea type="textarea" size="1200" name = "RequestDescription" id = "RequestDescription" style="width:475px; height :102px;" class="form-control" rows="5" ></textarea>

表单有2个提交按钮。

<input type="Submit" name ="sub" id ="sub" value="sub">
<input type="Submit" name ="submit" id ="submit" value ="Submit">

当单击第一个提交按钮时,文本区域中的数据将保存到数据库中的临时表中,以便用户可以随时编辑。

当单击第二个提交按钮时,文本区域中的数据将永久保存到表中,用户无法再对其进行编辑。

每当用户成功单击第一个提交按钮(使用ValidationTest函数进行验证返回true),直到成功单击第二个提交按钮时,我都希望显示带有文本区域的表单和临时数据库中的数据。

在此之前,在mysql中添加一个列"可编辑"的基于POST值的设置值,如下所示。

在操作中。php检查以下

if(isset($_POST['sub']) {
//here update your editable to 1 which means you can edit
}
else if(isset($_POST['submit']) {
//here update your editable to 0 which means you can't edit value
}

你还需要做的一件事是,在点击编辑值之前,你必须检查可编辑值。。如果它的0不允许编辑,如果它的1则允许用户编辑。