自动在输入框中填写数据 [英] Fill data in input boxes automatically

查看:111
本文介绍了自动在输入框中填写数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有四个输入框。如果用户填充第一个框并单击某个按钮,则应该使用第一个框中的值用户输入自动填充剩余的输入框。可以使用JavaScript来完成吗?或者我应该说用用户输入的最后一个数据预填充文本框?

在按钮单击时,调用此函数 p>

 函数fillValuesInTextBoxes()
{
var text = document.getElementById(firsttextbox).value;

document.getElementById(secondtextbox)。value = text;
document.getElementById(thirdtextbox)。value = text;
document.getElementById(fourthtextbox)。value = text;
}


I have four input boxes. If the user fills the first box and clicks a button then it should autofill the remaining input boxes with the value user input in the first box. Can it be done using javascript? Or I should say prefill the textboxes with the last data entered by the user?

解决方案

On button click, call this function

function fillValuesInTextBoxes()
{
    var text = document.getElementById("firsttextbox").value;

    document.getElementById("secondtextbox").value = text;
    document.getElementById("thirdtextbox").value = text;
    document.getElementById("fourthtextbox").value = text;
}

这篇关于自动在输入框中填写数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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