如何将输入框中的值传递给另一个输入框 [英] How Do I pass a value in a input box, to another input box

查看:128
本文介绍了如何将输入框中的值传递给另一个输入框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在框之间传递值。


$ b

因此,当用户键入第一个文本框时:

 < input type =textplaceholder =Your personal messageid =valbox>< / input> 
< input type =submitname =design1id =butvalvalue =Choose Design>< / input>

然后他们点击'选择设计'按钮,他们输入的内容被传递给另一个
输入文本框在同一页上。



这是我想要传递给它的第二个输入框。

 < input type =textclass =input-textname =billing_last_nameid =billing_last_nameplaceholder =value => 

任何帮助将不胜感激
谢谢

解决方案

实时演示



代替 submit 类型输入使用按钮键入输入。

HTML

 < input type =textplaceholder =Your personal messageid =valbox>< / input> 
< input type =buttonname =design1id =butvalvalue =Choose Design>< / input>
< input type =textclass =input-textname =billing_last_nameid =billing_last_nameplaceholder =value =>

JS

  window.onload = function(){
document.getElementById('butval')。onclick = function(){
document.getElementById('billing_last_name') .value = document.getElementById('valbox').value;
}
};


I am trying to pass values between boxes.

So, When a User types inside of the first text box:

<input type="text" placeholder="Your personal message" id="valbox"></input>
<input type="submit" name="design1" id="butval" value="Choose Design"></input>

Then they click the 'choose design' button, and what they typed in, gets passed to another input text box on the same page.

this is the second input box i want to pass it to.

<input type="text" class="input-text" name="billing_last_name" id="billing_last_name" placeholder="" value="">

Any help would be much appreciated thank you

解决方案

Live Demo

Instead of a submit type input use a button type input.

HTML

<input type="text" placeholder="Your personal message" id="valbox"></input>
<input type="button" name="design1" id="butval" value="Choose Design"></input>
<input type="text" class="input-text" name="billing_last_name" id="billing_last_name" placeholder="" value="">

JS

window.onload = function(){
    document.getElementById('butval').onclick = function(){
        document.getElementById('billing_last_name').value = document.getElementById('valbox').value;   
    }
}; 

这篇关于如何将输入框中的值传递给另一个输入框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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