我想要达到的目的与您捐款时所获得的相似,我希望用户从列表中选择金额,然后金额显示在文本输入中,那么如何使用javascript完成
html如下:
<div id="container">
<ul>
<li id="one"><a href="">$14</a> </li>
<li id="two"><a href="">$25</a></li>
<li id="three"><a href="">$36</a></li>
<li id="four"><a href="">$40</a></li>
<li id="five"><a href="">$200</a></li>
</ul>
<form method="post" action="" class="forms">
<label>
Amount Donated
<input id="value" type="text" name="amount" class="width-10" />
</label>
</form>
</div>
以下javascript:
var amountClicked = document.getElementById("one");
if (amountClicked.clicked == true) {
document.getElementById("value").value = "$14";
}
答案 0 :(得分:0)
<select id="currency" onchange="myFunction()">
<option value="14">$14</option >
<option value="25">$25</option >
<option value="36">$36</option >
<option value="40">$40</option >
<select>
<script>
function myFunction() {
var x = document.getElementById("currency").value;
document.getElementById("value").value =x;
}
</script>