gpt4 book ai didi

javascript - 如何使用 BTN 将文本从一个文本字段输入复制到另一个?

转载 作者:行者123 更新时间:2023-11-28 01:09:08 26 4
gpt4 key购买 nike

我需要将文本值从一个文本字段输入复制到另一个文本字段。我怎样才能做到这一点?我创建了一个 js fiddle,它有一个文本表单,一旦我点击编辑详细信息,就会弹出另一个表单。在那个新表单中,我希望能够在存在的任何文本字段中输入文本,然后点击保存。新输入的文本将被移动/复制/传输到屏幕上的原始文本字段。

这是 jsfiddle - https://jsfiddle.net/xsuh6pf7/2/

 <h1>Your Name and Address</h1>
<form action="/">
<div class="nameDiv">
Name: <input type="textbox" name="firstname" title="name" id="name">

<div class="dotOne"> ? </div>
<span class="nameHelp"> Please enter first and last name </span>

</div>
<br>
<div class="addressDiv">
Address: <input type="text" name="lastname" id="address">
<div class="dotTwo">?</div>
</div>
<br>
<div class="emailDiv">
Email:
<input type="text" name="Email" class="email">
<span class="dotThree">?</span>
</div>
<br>
<div class="numberDiv">
Phone number:
<input type="text" name="Phone number" class="number">
<span class="dotFour">?</span>
</div>
<br>
</form>
<button class="btn" onclick="openForm()">Edit Details</button>

<div id="container">
<button class="tablink" onclick="openPage('Name', this, 'grey')" id="defaultOpen">Name</button>
<button class="tablink" onclick="openPage('Address', this, 'grey')">Address</button>

<div id="Name" class="tabcontent">

<form>
<div class="nameDiv">
Title: <input type="text" name="firstname" title="name" class="name">
</div>
<br>
<div class="addressDiv">
Name: <input type="text" name="lastname" id="nameTransfer">
</div>
<br>
<div class="emailDiv">
Surname:
<input type="text" name="Email" id="LastNameTransfer">
</div>
<br>
<div class="numberDiv">
Email Address:
<input type="text" name="Phone number" class="number">
</div>
<br>
<div class="numberDiv">
Phone number:
<input type="text" name="Phone number" class="number">
</div>
<button type="submit" id="save-btn" onclick="moveContent()">Save</button>
</form>
</div>

<div id="Address" class="tabcontent">
<form>
<div class="nameDiv">
Line 1: <input type="text" name="firstname" value="Mickey" title="name" class="name">
</div>
<br>
<div class="addressDiv">
Line 2: <input type="text" name="lastname" value="Mouse" class="address">
</div>
<br>
<div class="emailDiv">
Suburb:
<input type="text" name="Email" value="Email" class="email">
</div>
<br>
<div class="numberDiv">
State:
<input type="text" name="Phone number" value="Phone number" class="number">
</div>
<br>
<div class="numberDiv">
Country:
<input type="text" name="Phone number" value="Phone number" class="number">
</div>
<button class="save-btn" onclick="">Save</button>
</form>
</div>
</div>

最佳答案

你可以使用

document.getElementbyId("textfieldToTransfer").value = document.getElementbyId("textfieldOfData").value;

关于按钮的功能。

关于javascript - 如何使用 BTN 将文本从一个文本字段输入复制到另一个?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52214276/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com