gpt4 book ai didi

javascript - 我想将我从多保管箱中选择的值显示到禁用的文本字段中,但我无法做到这一点。请告诉我我缺少什么

转载 作者:行者123 更新时间:2023-12-03 02:29:14 25 4
gpt4 key购买 nike

以下是我的表单 HTML 代码。此表单包含一些国家/地区字段,这些字段是多个下拉选择输入。

 <!DOCTYPE html>
<html>
<head>
<link rel="icon" href="\images\trademark_icon.png" type="image/gif" sizes="16x16">


</head>
<style>

<!--Blah Blah -->
</style>
<body>

<h2 ><img src="images/hero_logo.png" class="herologo" ><span class="form-title">Trademark Filing Application</span></h2><br>

<div>
<p style="padding-left:20px"><span class="error">* required field.</span></p>

<form action="insert.php" method="post" enctype="multipart/form-data">

<!-- Department -->

<b>Select Department:</b><span class="error"> *</span>
<select id="dept" name="department" required>
<option value="">Please Select...</option>
<option value="ceo">CEO Office</option>
<option value="global">Global</option>
<option value="marketing">Marketing</option>
<option value="parts">Parts</option>

</select>
<br><br><br>

<!-- Class -->

<b>Select Class:</b><span class="error"> *</span><br><br>
<input type="radio" id="wordradio" name="classs" value="Word" required>Word
<input type="radio" id="deviceradio" name="classs" value="Device" style="margin-left:20px">Device
<input type="radio" id="logoradio" name="classs" value="Logo" style="margin-left:20px">Logo
<input type="radio" id="soundradio" name="classs" value="Sound" style="margin-left:20px">Sound
<input type="radio" id="taglineradio" name="classs" value="Tagline" style="margin-left:20px">Tagline
<br><br><br>


<!-- Preferences -->


<b>Enter Preference(s):</b><br>
1. <input type="text" id="pref1" name="preference1" style="width:30%" placeholder="Preference 1" required>
<input type="file" id="prefbtn1" name="files[]" multiple="" required>
<span class="error">*</span>
<br>

2. <input type="text" id="pref2" name="preference2" style="width:30%" placeholder="Preference 2">
<input type="file" id="prefbtn2" name="files[]" multiple="" >

<br>
3. <input type="text" id="pref3" name="preference3" style="width:30%" placeholder="Preference 3">
<input type="file" id="prefbtn3" name="files[]" multiple="" >

<br>
4. <input type="text" id="pref4" name="preference4" style="width:30%" placeholder="Preference 4">
<input type="file" id="prefbtn4" name="files[]" multiple="" >

<br>
5. <input type="text" id="pref5" name="preference5" style="width:30%" placeholder="Preference 5">
<input type="file" id="prefbtn5" name="files[]" multiple="" >

<br><br><br>


<!-- Goods and Services -->


<b>Enter The Types of Goods & Services :</b><span class="error"> *</span>
<br>
<input type="text" id="goodss" name="goodsnservice" placeholder="Select the type of Goods and Services" required>

<br><br><br>


<!-- Mark in Use? -->

<b>Is Mark In Use?</b><span class="error"> *</span><br><br>
<input type="radio" id="marky" name="mark" value="yes" onclick="disableNo()" required>Yes


<!-- Mark in Use?: YES -->


<div id="markyes" class="show-hide" style="background-color:white;width:600px ;margin-left:40px; border:1px solid black; border-radius:5px"><br>
<b>When Did You Use It?</b>
<input type="date" name="yeswhen" style="margin-left:10px" id="markyesdate" required><span class="error"> *</span><br><br>

<b>Where Did You Use It?</b><span class="error"> *</span><br>
<select name="yescountry[]" style="width:20%" id="markyescountry" multiple required>
<option value="Afghanistan">Afghanistan</option>
<option value="Yemen">Yemen</option>
<option value="Zaire">Zaire</option>
<option value="Zambia">Zambia</option>
<option value="Zimbabwe">Zimbabwe</option>
</select><br><br>

<b>Proof Of First Use:</b><span class="error"> *</span><br>
<input type="file" id="markyesproof" name="files[]" value="Upload one or more files" multiple="" required>
</div><br>


<!-- Mark in Use?: NO -->


<input type="radio" name="mark" value="no" onclick="disableYes()" >No<br>
<div id="markno" class="show-hide" style="background-color:white;width:600px ;margin-left:40px; border:1px solid black; border-radius:5px"><br>
<b>When Are You Expected To Use It?</b>
<input type="date" name="nowhen" style="margin-left:10px" id="marknodate" required><span class="error"> *</span><br><br>

<b>Where will You Use It?</b><span class="error"> *</span><br>

<select name="nocountry[]" style="width:20%" id="marknocountry" multiple required>
<option value="Afghanistan">Afghanistan</option>
<option value="Albania">Albania</option>
<option value="Algeria">Algeria</option>
<option value="American">American Samoa</option>
<option value="Zaire">Zaire</option>
<option value="Zambia">Zambia</option>
<option value="Zimbabwe">Zimbabwe</option>
</select><br><br>

</div><br>


<!-- Mark Applied Country -->


<b style="text-height:50%">Mark Applied Country:</b><br>

<select name="markappliedcountry" id="multi-country" class="dropdown-country" style="width:20%" multiple >

<option value="Afghanistan">Afghanistan</option>
<option value="Albania">Albania</option>
<option value="Algeria">Algeria</option>
<option value="Zambia">Zambia</option>
<option value="Zimbabwe">Zimbabwe</option>
</select><br><br>

<br><br><br>
<input type="text" id="selected_values" name="multiple_selected_values" disabled/><br/><br/>

<input type="submit" value="Submit">
</form>
</div>

<script>
function disableNo() {
document.getElementById("marknocountry").required = false;
document.getElementById("marknodate").required = false;
}

function disableYes() {
document.getElementById("markyescountry").required = false;
document.getElementById("markyesdate").required = false;
document.getElementById("markyesproof").required = false;
}


var selText;
$('select').on('change', function() {
selText ="";
$("#multi-country").each(function () {
var $this = $(this);
if(selText !=""){
selText = selText.concat(",");
selText = selText.concat($this.text());
}
else
selText=$this.text();
});
//alert(selText);
document.getElementById("selected_values").value=selText;
});

</script>


</body>
</html>

I want these selected values to be displayed in the field below.

我试图首先在“应用国家”(最后一个)上使用它,这样如果它有效,我也会将其复制到其他领域。另外,有什么方法可以为三个不同的选择输入重复使用相同的下拉列表吗?

最佳答案

我认为应该可以完成这项工作:

<select name="markappliedcountry" id="multi-country" class="dropdown-country" style="width:20%" multiple >
<option value="Afghanistan">Afghanistan</option>
<option value="Albania">Albania</option>
<option value="Algeria">Algeria</option>
<option value="Zambia">Zambia</option>
<option value="Zimbabwe">Zimbabwe</option>
</select>
<input type="text" id="selected_values" name="multiple_selected_values" disabled/>

JS:

$(document).ready(function() {
$('select').on('change', function() {
$('input').val($(this).val());
});
});

JSFiddle example

关于javascript - 我想将我从多保管箱中选择的值显示到禁用的文本字段中,但我无法做到这一点。请告诉我我缺少什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48802840/

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