Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/251.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 附录页上的“清除”按钮不';行不通_Javascript_Php_Html_Css - Fatal编程技术网

Javascript 附录页上的“清除”按钮不';行不通

Javascript 附录页上的“清除”按钮不';行不通,javascript,php,html,css,Javascript,Php,Html,Css,这是我的addentry博客页面,我从头开始做的,这段代码有潜在的问题,特别是clear按钮,当点击按钮时,它应该清除任何输入的文本,但它不起作用。我已经将其保存为html文件,这就是问题所在 另外一个问题是submit按钮,它可以工作,但它不会将任何文本传递到我以php编写的索引文件,出于某种原因,每当我单击submit按钮时,它就会将我重定向回索引页面,而不会发布我所做的条目 <!DOCTYPE html> <html> <head> <scrip

这是我的addentry博客页面,我从头开始做的,这段代码有潜在的问题,特别是clear按钮,当点击按钮时,它应该清除任何输入的文本,但它不起作用。我已经将其保存为html文件,这就是问题所在

另外一个问题是submit按钮,它可以工作,但它不会将任何文本传递到我以php编写的索引文件,出于某种原因,每当我单击submit按钮时,它就会将我重定向回索引页面,而不会发布我所做的条目

<!DOCTYPE html>
<html>
<head>

<script>
function message() {
    alert("Clear the form?");
}
</script>

<style>
body {background-color: beige;}
h1   {color: black;}
p    {color: black;}

textarea
{
    width: 50%;
    height: 150px;
    padding: 12px 20px;
    box-sizing: border-box;
    border: 2px solid #ccc;
    border-radius: 4px;
    background-color: white;
    font-size: 16px;
    resize: none;
}


div
{
    padding-left: 20px;
}

</style>
</head>
<meta charset="utf-8">

<link rel="stylesheet" href="../../main.css">
<title>Add an entry</title>
</head>

<body>

<div><h1>Add an entry</h1></div>
<div><p><b>Enter the title of the entry so the topic is clearly defined and then add the entry for the blog that you want to write about after finishing writing about your topic press the submit button to submit the entry which will be posted in the main page of the blog however if you wish to discard or clear your entry then press the clear button to remove your topic which you have written about.</b></p></div>


<form onreset="message()">
    <p><label>Title</label>
    <input type = "text" id = "myText"/></p>

    <p><label>Entry</label>
    <textarea>
<input type="clear">
</form>



<form>
    <p><label>Title</label>
    <input type = "text" id = "myText"/></p>

    <p><label>Entry</label>
    <textarea>

    </textarea></p>

</form>


<form method="post" action="index.html">
<button type="submit" value="Submit">Submit</button>  <input type="button" value="Clear" onclick="javascript:eraseText();">
</form>
</body>
</html>

函数消息(){
警报(“清除表单?”);
}
主体{背景颜色:米色;}
h1{颜色:黑色;}
p{颜色:黑色;}
文本区
{
宽度:50%;
高度:150像素;
填充:12px 20px;
框大小:边框框;
边框:2个实心#ccc;
边界半径:4px;
背景色:白色;
字体大小:16px;
调整大小:无;
}
div
{
左侧填充:20px;
}
添加条目
添加条目
输入条目标题,以便明确定义主题,然后在完成主题写作后为您想要撰写的博客添加条目。按“提交”按钮提交将发布在博客主页上的条目。但是,如果您希望放弃或清除条目,请按“清除”按钮以删除您所写的主题

头衔

入口 头衔

入口

提交
尤其是清除按钮代码的这一部分:

<script>
    function message() {
        alert("Clear the form?");
    }
</script>

<form onreset="message()">
    <p><label>Title</label>
    <input type = "text" id = "myText"/></p>

    <p><label>Entry</label>
    <textarea>
    <input type="clear">
</form>
<form method="post" action="index.html">
    <button type="submit" value="Submit">Submit</button>
    <input type="button" value="Clear" onclick="javascript:eraseText();">
</form>

函数消息(){
警报(“清除表单?”);
}
头衔

入口
这是提交按钮代码:

<script>
    function message() {
        alert("Clear the form?");
    }
</script>

<form onreset="message()">
    <p><label>Title</label>
    <input type = "text" id = "myText"/></p>

    <p><label>Entry</label>
    <textarea>
    <input type="clear">
</form>
<form method="post" action="index.html">
    <button type="submit" value="Submit">Submit</button>
    <input type="button" value="Clear" onclick="javascript:eraseText();">
</form>

提交
1)只需将输入字段与
type=“reset”
一起使用,即可清除表单

2) 所有的输入字段都应该是相同的表单,只有它会发布到下一页

注意:您正在使用多个表单,并且在索引页上需要其他表单值


标题


进入

提交
废话
。。。它看起来也像是在一个文本区域中有一个输入,所以我不能保证那里会发生什么
action=“index.html”
你在这里把这个html文件当作php运行了吗?正如Dale指出的,你可以使用
reset
,但也可以在你展示的源代码中使用
eraseText()
不存在…并且您的
message()
JS函数所做的一切都是警报。现在又回到绘图板上了。