如何将文本添加到表单输入 [英] How to add text to form input

查看:81
本文介绍了如何将文本添加到表单输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我真的不确定从哪里开始.我有一个表单输入框和提交按钮.当按下提交按钮时,表单内容将被提交并在某些javascript中使用.我想做的是自动在提交的末尾添加一些文本.

I am really not sure where to start with this. I have a form input box and submit button. When the submit button is pressed, the form content is submitted and used in some javascript. What I want to do is automatically add some text to the end of the submission.

因此,如果用户输入狗走路了"并按了提交,则该表单将添加过马路".到提交的末尾.

So if a user inputs "The dog walked" and pressed submit, the form would add "across the street." to the end of the submission.

谢谢!

推荐答案

在事件监听器中,针对表单的Submit操作,更改输入.

In your event listener for the form's submit action, change the input.

document.getElementById('theinputid').value = document.getElementById('theinputid').value + "across the street."

这篇关于如何将文本添加到表单输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆