如何编辑表单中的提交值?

时间:2022-12-06 22:14:53

I have a text area on my site which shows the user a certain value. The problem is that when i click the text area (form) and press enter, it shows a 404 error. How can I edit my existing html code to remove the submit/enter action, so that the page doesnt lead to a 404?

我的网站上有一个文本区域,向用户显示一定的值。问题是,当我单击文本区域(窗体)并按Enter键时,它显示404错误。如何编辑现有的html代码以删除提交/输入操作,以便页面不会导致404?

Here's my code:

这是我的代码:

<input type="text" name="postLink" size="48" value="This is a value!" />

2 个解决方案

#1


3  

You should have an <input type="submit> field somewhere. Delete that. Or, remove the encapsulating <form> tag.

你应该在某个地方有一个字段。删除它。或者,删除封装的

标记。

#2


0  

The answer depends a little on what you are trying to do... if you can clarify the intent of the question, it will help us clarify our answers.

答案取决于你想要做什么......如果你能澄清问题的意图,它将帮助我们澄清我们的答案。

If you are doing this to allow for new lines in the box, you may want to look at using a <textarea> instead of <input type="text" />. (And even if you're doing this for other reasons, this may still be a better option)

如果您这样做是为了允许框中的新行,您可能希望使用。 (即使你出于其他原因这样做,这可能仍然是一个更好的选择)

If you're doing this to just display something (and not allow for edits/submissions) you may want to disable the form item (add disabled="disabled" to the element). If this is your goal, there may be some other/better ways to do this.

如果您这样做只是为了显示某些内容(并且不允许编辑/提交),您可能需要禁用表单项(对该元素添加disabled =“disabled”)。如果这是您的目标,可能还有其他一些/更好的方法可以做到这一点。

Depending on what you're doing, you could also add a little JavaScript to the page to capture and ignore the return key - just keep in mind this does no good if they have JavaScript disabled, and it may cause some undesirable side-effects like not being able to add new lines to a text area. The following, and dozens of variants can be found floating around the 'net.

根据您正在做的事情,您还可以在页面中添加一些JavaScript来捕获并忽略返回键 - 请记住,如果禁用了JavaScript,这没有任何好处,并且可能会导致一些不良副作用,例如无法在文本区域添加新行。以下,可以找到几十个变种浮在'网上。

document.onkeydown = function(){
  if(window.event.keyCode==13) return false
}

You could remove the submit button, but IE will still submit the form if there is only one element in the form, and FireFox will always submit the form uppon pressing Enter. I don't recall what Chrome and Opera do, but the point remains that deleting the submit button will not give you what you want across the board.

您可以删除提交按钮,但如果表单中只有一个元素,IE仍会提交表单,FireFox将始终按Enter键提交表单。我不记得Chrome和Opera做了什么,但重点仍然是删除提交按钮不会给你你想要的全面。

#1


3  

You should have an <input type="submit> field somewhere. Delete that. Or, remove the encapsulating <form> tag.

你应该在某个地方有一个字段。删除它。或者,删除封装的

标记。

#2


0  

The answer depends a little on what you are trying to do... if you can clarify the intent of the question, it will help us clarify our answers.

答案取决于你想要做什么......如果你能澄清问题的意图,它将帮助我们澄清我们的答案。

If you are doing this to allow for new lines in the box, you may want to look at using a <textarea> instead of <input type="text" />. (And even if you're doing this for other reasons, this may still be a better option)

如果您这样做是为了允许框中的新行,您可能希望使用。 (即使你出于其他原因这样做,这可能仍然是一个更好的选择)

If you're doing this to just display something (and not allow for edits/submissions) you may want to disable the form item (add disabled="disabled" to the element). If this is your goal, there may be some other/better ways to do this.

如果您这样做只是为了显示某些内容(并且不允许编辑/提交),您可能需要禁用表单项(对该元素添加disabled =“disabled”)。如果这是您的目标,可能还有其他一些/更好的方法可以做到这一点。

Depending on what you're doing, you could also add a little JavaScript to the page to capture and ignore the return key - just keep in mind this does no good if they have JavaScript disabled, and it may cause some undesirable side-effects like not being able to add new lines to a text area. The following, and dozens of variants can be found floating around the 'net.

根据您正在做的事情,您还可以在页面中添加一些JavaScript来捕获并忽略返回键 - 请记住,如果禁用了JavaScript,这没有任何好处,并且可能会导致一些不良副作用,例如无法在文本区域添加新行。以下,可以找到几十个变种浮在'网上。

document.onkeydown = function(){
  if(window.event.keyCode==13) return false
}

You could remove the submit button, but IE will still submit the form if there is only one element in the form, and FireFox will always submit the form uppon pressing Enter. I don't recall what Chrome and Opera do, but the point remains that deleting the submit button will not give you what you want across the board.

您可以删除提交按钮,但如果表单中只有一个元素,IE仍会提交表单,FireFox将始终按Enter键提交表单。我不记得Chrome和Opera做了什么,但重点仍然是删除提交按钮不会给你你想要的全面。