【发布时间】:2020-08-23 09:01:38
【问题描述】:
我正在尝试根据选择选择显示 txt 文件中的数据值
<?php
$lines = file('customers.txt');
?>
<select class="select" style="width: 250px;" name="mylist" id="mylist" required="">
<option selected="selected" value="">Select Your Company</option>
<?php foreach($lines as $line){
$customers = explode(',', $line);
echo "<option value='".$customers[0]."'>$customers[0] </option>"; }?>
</select>
<input type="text" id="inputid" placeholder="Company Name">
和我尝试的 js
<script>
$(".select").change(function(){
var res = $(".select").find(":selected").map(function () {
if($(this).val()!="")
return $(this).text();
else
return "";
}).get().join("");
$("#inputid").val(res);
});
</script>
我的customers.txt 数据文件:-
客户1,街道,分机,邮政编码
客户 2,B 街道,B 分机,B 邮政编码
客户 3,C 街道,C 分机,C 邮政编码
...等
在选择 Customer1 时,我想在 :-
中显示客户1
一条街
扩展
邮政编码
【问题讨论】:
标签: javascript php list