Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/427.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/241.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在文本框中显示我选择的dropdownlist值_Javascript_Php_Jquery_Html - Fatal编程技术网

Javascript 如何在文本框中显示我选择的dropdownlist值

Javascript 如何在文本框中显示我选择的dropdownlist值,javascript,php,jquery,html,Javascript,Php,Jquery,Html,我有一个代码,用于填充从文本文件到列表框的单词。如果我从列表框中选择了任何值,那么它会在文本框中显示一个选定的单词(在表单中-将该值发布到另一个脚本) javascript代码: <script> function getSelectedValue(theValue){ document.getElementById('pasteTheValue').innerHTML=theValue; } </script> //open the file $rea

我有一个代码,用于填充从文本文件到列表框的单词。如果我从列表框中选择了任何值,那么它会在文本框中显示一个选定的单词(在表单中-将该值发布到另一个脚本)

javascript代码:

<script>
  function getSelectedValue(theValue){
    document.getElementById('pasteTheValue').innerHTML=theValue;
  }
</script>
//open the file
$read_your_file = @fopen($your_file, "r") or die ("Couldn't Access $your_file");

//create a variable to hold the contents of the file
$contents_your_file = fread($read_your_file, filesize($your_file));

//array of file contents
$your_array = explode("\n",$contents_your_file);

//close the file
fclose($read_your_file);

//counts the number elements in the property_categories array
$num_elmnts_array = count($your_array) ;

//elements in the drop down list
//$drop_elmnts = 0;

//begin creating your dropdown menu...

$your_menu = "<select name=\"list\" onchange=\"getSelectedValue(this.value)\">";  
//For loop to begin
for($counter = 0; $counter < $num_elmnts_array; $counter++){
$your_menu .= "<option value=\"$your_array[$counter]\">$your_array[$counter]        </option>";
//$counter++;
}
//end select menu
$your_menu .= "</select>";
?>

<p><b><?php echo "$your_menu"; ?></b><br>
<p id="pasteTheValue"></p>
 function getSelectedValue(theValue){
     document.getElementById('my_textbox').value=theValue; // add this line
    }

函数getSelectedValue(theValue){
document.getElementById('pasteTheValue')。innerHTML=theValue;
}
php代码:
//open the file
$read_your_file = @fopen($your_file, "r") or die ("Couldn't Access $your_file");

//create a variable to hold the contents of the file
$contents_your_file = fread($read_your_file, filesize($your_file));

//array of file contents
$your_array = explode("\n",$contents_your_file);

//close the file
fclose($read_your_file);

//counts the number elements in the property_categories array
$num_elmnts_array = count($your_array) ;

//elements in the drop down list
//$drop_elmnts = 0;

//begin creating your dropdown menu...

$your_menu = "<select name=\"list\" onchange=\"getSelectedValue(this.value)\">";  
//For loop to begin
for($counter = 0; $counter < $num_elmnts_array; $counter++){
$your_menu .= "<option value=\"$your_array[$counter]\">$your_array[$counter]        </option>";
//$counter++;
}
//end select menu
$your_menu .= "</select>";
?>

<p><b><?php echo "$your_menu"; ?></b><br>
<p id="pasteTheValue"></p>
//打开文件
$read_your_file=@fopen($your_file,“r”)或die(“无法访问$your_文件”);
//创建一个变量来保存文件的内容
$contents\u your\u file=fread($read\u your\u file,filesize($your\u file));
//文件内容数组
$your\u array=explode(“\n”,$contents\u your\u文件);
//关闭文件
fclose($read\u your\u file);
//统计属性类别数组中的元素数
$num\u elmnts\u array=count($your\u array);
//下拉列表中的元素
//$drop_elmnts=0;
//开始创建您的下拉菜单。。。
$your_menu=“”;
//让循环开始
对于($counter=0;$counter<$num\u elmnts\u数组;$counter++){
$your_菜单。=“$your_数组[$counter]”;
//$counter++;
}
//结束选择菜单
$您的菜单。=“”;
?>


这个很好用。这将在页面中显示所选单词,与正常文本一样。但我想在文本框中显示(或获取值)。请帮我解决这个问题。

使用id如下的文本框

<input type="text" id="my_textbox" value="" />
更新2:

<script>
  function getSelectedValue(theValue){
    document.getElementById('pasteTheValue').innerHTML=theValue;
  }
</script>
//open the file
$read_your_file = @fopen($your_file, "r") or die ("Couldn't Access $your_file");

//create a variable to hold the contents of the file
$contents_your_file = fread($read_your_file, filesize($your_file));

//array of file contents
$your_array = explode("\n",$contents_your_file);

//close the file
fclose($read_your_file);

//counts the number elements in the property_categories array
$num_elmnts_array = count($your_array) ;

//elements in the drop down list
//$drop_elmnts = 0;

//begin creating your dropdown menu...

$your_menu = "<select name=\"list\" onchange=\"getSelectedValue(this.value)\">";  
//For loop to begin
for($counter = 0; $counter < $num_elmnts_array; $counter++){
$your_menu .= "<option value=\"$your_array[$counter]\">$your_array[$counter]        </option>";
//$counter++;
}
//end select menu
$your_menu .= "</select>";
?>

<p><b><?php echo "$your_menu"; ?></b><br>
<p id="pasteTheValue"></p>
 function getSelectedValue(theValue){
     document.getElementById('my_textbox').value=theValue; // add this line
    }

使用id如下的文本框

<input type="text" id="my_textbox" value="" />
更新2:

<script>
  function getSelectedValue(theValue){
    document.getElementById('pasteTheValue').innerHTML=theValue;
  }
</script>
//open the file
$read_your_file = @fopen($your_file, "r") or die ("Couldn't Access $your_file");

//create a variable to hold the contents of the file
$contents_your_file = fread($read_your_file, filesize($your_file));

//array of file contents
$your_array = explode("\n",$contents_your_file);

//close the file
fclose($read_your_file);

//counts the number elements in the property_categories array
$num_elmnts_array = count($your_array) ;

//elements in the drop down list
//$drop_elmnts = 0;

//begin creating your dropdown menu...

$your_menu = "<select name=\"list\" onchange=\"getSelectedValue(this.value)\">";  
//For loop to begin
for($counter = 0; $counter < $num_elmnts_array; $counter++){
$your_menu .= "<option value=\"$your_array[$counter]\">$your_array[$counter]        </option>";
//$counter++;
}
//end select menu
$your_menu .= "</select>";
?>

<p><b><?php echo "$your_menu"; ?></b><br>
<p id="pasteTheValue"></p>
 function getSelectedValue(theValue){
     document.getElementById('my_textbox').value=theValue; // add this line
    }

使用id如下的文本框

<input type="text" id="my_textbox" value="" />
更新2:

<script>
  function getSelectedValue(theValue){
    document.getElementById('pasteTheValue').innerHTML=theValue;
  }
</script>
//open the file
$read_your_file = @fopen($your_file, "r") or die ("Couldn't Access $your_file");

//create a variable to hold the contents of the file
$contents_your_file = fread($read_your_file, filesize($your_file));

//array of file contents
$your_array = explode("\n",$contents_your_file);

//close the file
fclose($read_your_file);

//counts the number elements in the property_categories array
$num_elmnts_array = count($your_array) ;

//elements in the drop down list
//$drop_elmnts = 0;

//begin creating your dropdown menu...

$your_menu = "<select name=\"list\" onchange=\"getSelectedValue(this.value)\">";  
//For loop to begin
for($counter = 0; $counter < $num_elmnts_array; $counter++){
$your_menu .= "<option value=\"$your_array[$counter]\">$your_array[$counter]        </option>";
//$counter++;
}
//end select menu
$your_menu .= "</select>";
?>

<p><b><?php echo "$your_menu"; ?></b><br>
<p id="pasteTheValue"></p>
 function getSelectedValue(theValue){
     document.getElementById('my_textbox').value=theValue; // add this line
    }

使用id如下的文本框

<input type="text" id="my_textbox" value="" />
更新2:

<script>
  function getSelectedValue(theValue){
    document.getElementById('pasteTheValue').innerHTML=theValue;
  }
</script>
//open the file
$read_your_file = @fopen($your_file, "r") or die ("Couldn't Access $your_file");

//create a variable to hold the contents of the file
$contents_your_file = fread($read_your_file, filesize($your_file));

//array of file contents
$your_array = explode("\n",$contents_your_file);

//close the file
fclose($read_your_file);

//counts the number elements in the property_categories array
$num_elmnts_array = count($your_array) ;

//elements in the drop down list
//$drop_elmnts = 0;

//begin creating your dropdown menu...

$your_menu = "<select name=\"list\" onchange=\"getSelectedValue(this.value)\">";  
//For loop to begin
for($counter = 0; $counter < $num_elmnts_array; $counter++){
$your_menu .= "<option value=\"$your_array[$counter]\">$your_array[$counter]        </option>";
//$counter++;
}
//end select menu
$your_menu .= "</select>";
?>

<p><b><?php echo "$your_menu"; ?></b><br>
<p id="pasteTheValue"></p>
 function getSelectedValue(theValue){
     document.getElementById('my_textbox').value=theValue; // add this line
    }

要获取所选值,需要在JavaScript中使用
.value
,在jQuery中使用
.val()

使用JavaScript

//open the file
$read_your_file = @fopen($your_file, "r") or die ("Couldn't Access $your_file");

//create a variable to hold the contents of the file
$contents_your_file = fread($read_your_file, filesize($your_file));

//array of file contents
$your_array = explode("\n",$contents_your_file);

//close the file
fclose($read_your_file);

//counts the number elements in the property_categories array
$num_elmnts_array = count($your_array) ;

//elements in the drop down list
//$drop_elmnts = 0;

//begin creating your dropdown menu...

$your_menu = "<select name=\"list\" onchange=\"getSelectedValue(this.value)\">";  
//For loop to begin
for($counter = 0; $counter < $num_elmnts_array; $counter++){
$your_menu .= "<option value=\"$your_array[$counter]\">$your_array[$counter]        </option>";
//$counter++;
}
//end select menu
$your_menu .= "</select>";
?>

<p><b><?php echo "$your_menu"; ?></b><br>
<p id="pasteTheValue"></p>
function getSelectedValue(theValue){
var SelectedValue = theValue.options[theValue.selectedIndex].value;
document.getElementById('pasteTheValue').innerHTML=SelectedValue ;
}
使用jQuery

//open the file
$read_your_file = @fopen($your_file, "r") or die ("Couldn't Access $your_file");

//create a variable to hold the contents of the file
$contents_your_file = fread($read_your_file, filesize($your_file));

//array of file contents
$your_array = explode("\n",$contents_your_file);

//close the file
fclose($read_your_file);

//counts the number elements in the property_categories array
$num_elmnts_array = count($your_array) ;

//elements in the drop down list
//$drop_elmnts = 0;

//begin creating your dropdown menu...

$your_menu = "<select name=\"list\" onchange=\"getSelectedValue(this.value)\">";  
//For loop to begin
for($counter = 0; $counter < $num_elmnts_array; $counter++){
$your_menu .= "<option value=\"$your_array[$counter]\">$your_array[$counter]        </option>";
//$counter++;
}
//end select menu
$your_menu .= "</select>";
?>

<p><b><?php echo "$your_menu"; ?></b><br>
<p id="pasteTheValue"></p>
$('select').change(function () {
var SelectedValue = $('select').val();
$('#pasteTheValue').innerHTML = SelectedValue;
}

来源:
这里有一个完整的教程,介绍如何使用JavaScript中的
.value
和jQuery中的
.val()
获取所选值

使用JavaScript

//open the file
$read_your_file = @fopen($your_file, "r") or die ("Couldn't Access $your_file");

//create a variable to hold the contents of the file
$contents_your_file = fread($read_your_file, filesize($your_file));

//array of file contents
$your_array = explode("\n",$contents_your_file);

//close the file
fclose($read_your_file);

//counts the number elements in the property_categories array
$num_elmnts_array = count($your_array) ;

//elements in the drop down list
//$drop_elmnts = 0;

//begin creating your dropdown menu...

$your_menu = "<select name=\"list\" onchange=\"getSelectedValue(this.value)\">";  
//For loop to begin
for($counter = 0; $counter < $num_elmnts_array; $counter++){
$your_menu .= "<option value=\"$your_array[$counter]\">$your_array[$counter]        </option>";
//$counter++;
}
//end select menu
$your_menu .= "</select>";
?>

<p><b><?php echo "$your_menu"; ?></b><br>
<p id="pasteTheValue"></p>
function getSelectedValue(theValue){
var SelectedValue = theValue.options[theValue.selectedIndex].value;
document.getElementById('pasteTheValue').innerHTML=SelectedValue ;
}
使用jQuery

//open the file
$read_your_file = @fopen($your_file, "r") or die ("Couldn't Access $your_file");

//create a variable to hold the contents of the file
$contents_your_file = fread($read_your_file, filesize($your_file));

//array of file contents
$your_array = explode("\n",$contents_your_file);

//close the file
fclose($read_your_file);

//counts the number elements in the property_categories array
$num_elmnts_array = count($your_array) ;

//elements in the drop down list
//$drop_elmnts = 0;

//begin creating your dropdown menu...

$your_menu = "<select name=\"list\" onchange=\"getSelectedValue(this.value)\">";  
//For loop to begin
for($counter = 0; $counter < $num_elmnts_array; $counter++){
$your_menu .= "<option value=\"$your_array[$counter]\">$your_array[$counter]        </option>";
//$counter++;
}
//end select menu
$your_menu .= "</select>";
?>

<p><b><?php echo "$your_menu"; ?></b><br>
<p id="pasteTheValue"></p>
$('select').change(function () {
var SelectedValue = $('select').val();
$('#pasteTheValue').innerHTML = SelectedValue;
}

来源:
这里有一个完整的教程,介绍如何使用JavaScript中的
.value
和jQuery中的
.val()
获取所选值

使用JavaScript

//open the file
$read_your_file = @fopen($your_file, "r") or die ("Couldn't Access $your_file");

//create a variable to hold the contents of the file
$contents_your_file = fread($read_your_file, filesize($your_file));

//array of file contents
$your_array = explode("\n",$contents_your_file);

//close the file
fclose($read_your_file);

//counts the number elements in the property_categories array
$num_elmnts_array = count($your_array) ;

//elements in the drop down list
//$drop_elmnts = 0;

//begin creating your dropdown menu...

$your_menu = "<select name=\"list\" onchange=\"getSelectedValue(this.value)\">";  
//For loop to begin
for($counter = 0; $counter < $num_elmnts_array; $counter++){
$your_menu .= "<option value=\"$your_array[$counter]\">$your_array[$counter]        </option>";
//$counter++;
}
//end select menu
$your_menu .= "</select>";
?>

<p><b><?php echo "$your_menu"; ?></b><br>
<p id="pasteTheValue"></p>
function getSelectedValue(theValue){
var SelectedValue = theValue.options[theValue.selectedIndex].value;
document.getElementById('pasteTheValue').innerHTML=SelectedValue ;
}
使用jQuery

//open the file
$read_your_file = @fopen($your_file, "r") or die ("Couldn't Access $your_file");

//create a variable to hold the contents of the file
$contents_your_file = fread($read_your_file, filesize($your_file));

//array of file contents
$your_array = explode("\n",$contents_your_file);

//close the file
fclose($read_your_file);

//counts the number elements in the property_categories array
$num_elmnts_array = count($your_array) ;

//elements in the drop down list
//$drop_elmnts = 0;

//begin creating your dropdown menu...

$your_menu = "<select name=\"list\" onchange=\"getSelectedValue(this.value)\">";  
//For loop to begin
for($counter = 0; $counter < $num_elmnts_array; $counter++){
$your_menu .= "<option value=\"$your_array[$counter]\">$your_array[$counter]        </option>";
//$counter++;
}
//end select menu
$your_menu .= "</select>";
?>

<p><b><?php echo "$your_menu"; ?></b><br>
<p id="pasteTheValue"></p>
$('select').change(function () {
var SelectedValue = $('select').val();
$('#pasteTheValue').innerHTML = SelectedValue;
}

来源:
这里有一个完整的教程,介绍如何使用JavaScript中的
.value
和jQuery中的
.val()
获取所选值

使用JavaScript

//open the file
$read_your_file = @fopen($your_file, "r") or die ("Couldn't Access $your_file");

//create a variable to hold the contents of the file
$contents_your_file = fread($read_your_file, filesize($your_file));

//array of file contents
$your_array = explode("\n",$contents_your_file);

//close the file
fclose($read_your_file);

//counts the number elements in the property_categories array
$num_elmnts_array = count($your_array) ;

//elements in the drop down list
//$drop_elmnts = 0;

//begin creating your dropdown menu...

$your_menu = "<select name=\"list\" onchange=\"getSelectedValue(this.value)\">";  
//For loop to begin
for($counter = 0; $counter < $num_elmnts_array; $counter++){
$your_menu .= "<option value=\"$your_array[$counter]\">$your_array[$counter]        </option>";
//$counter++;
}
//end select menu
$your_menu .= "</select>";
?>

<p><b><?php echo "$your_menu"; ?></b><br>
<p id="pasteTheValue"></p>
function getSelectedValue(theValue){
var SelectedValue = theValue.options[theValue.selectedIndex].value;
document.getElementById('pasteTheValue').innerHTML=SelectedValue ;
}
使用jQuery

//open the file
$read_your_file = @fopen($your_file, "r") or die ("Couldn't Access $your_file");

//create a variable to hold the contents of the file
$contents_your_file = fread($read_your_file, filesize($your_file));

//array of file contents
$your_array = explode("\n",$contents_your_file);

//close the file
fclose($read_your_file);

//counts the number elements in the property_categories array
$num_elmnts_array = count($your_array) ;

//elements in the drop down list
//$drop_elmnts = 0;

//begin creating your dropdown menu...

$your_menu = "<select name=\"list\" onchange=\"getSelectedValue(this.value)\">";  
//For loop to begin
for($counter = 0; $counter < $num_elmnts_array; $counter++){
$your_menu .= "<option value=\"$your_array[$counter]\">$your_array[$counter]        </option>";
//$counter++;
}
//end select menu
$your_menu .= "</select>";
?>

<p><b><?php echo "$your_menu"; ?></b><br>
<p id="pasteTheValue"></p>
$('select').change(function () {
var SelectedValue = $('select').val();
$('#pasteTheValue').innerHTML = SelectedValue;
}

来源:
这里有一个完整的教程,介绍如何将下拉列表元素id视为myDropDown
//open the file
$read_your_file = @fopen($your_file, "r") or die ("Couldn't Access $your_file");

//create a variable to hold the contents of the file
$contents_your_file = fread($read_your_file, filesize($your_file));

//array of file contents
$your_array = explode("\n",$contents_your_file);

//close the file
fclose($read_your_file);

//counts the number elements in the property_categories array
$num_elmnts_array = count($your_array) ;

//elements in the drop down list
//$drop_elmnts = 0;

//begin creating your dropdown menu...

$your_menu = "<select name=\"list\" onchange=\"getSelectedValue(this.value)\">";  
//For loop to begin
for($counter = 0; $counter < $num_elmnts_array; $counter++){
$your_menu .= "<option value=\"$your_array[$counter]\">$your_array[$counter]        </option>";
//$counter++;
}
//end select menu
$your_menu .= "</select>";
?>

<p><b><?php echo "$your_menu"; ?></b><br>
<p id="pasteTheValue"></p>
现在,您的任务可以按如下所示完成:

$("#myDropDown").change(function(){
   var selectedValue = $(this).val();
   $("#pasteTheValue").val(selectedValue);
});

将下拉列表元素id视为myDropDown
//open the file
$read_your_file = @fopen($your_file, "r") or die ("Couldn't Access $your_file");

//create a variable to hold the contents of the file
$contents_your_file = fread($read_your_file, filesize($your_file));

//array of file contents
$your_array = explode("\n",$contents_your_file);

//close the file
fclose($read_your_file);

//counts the number elements in the property_categories array
$num_elmnts_array = count($your_array) ;

//elements in the drop down list
//$drop_elmnts = 0;

//begin creating your dropdown menu...

$your_menu = "<select name=\"list\" onchange=\"getSelectedValue(this.value)\">";  
//For loop to begin
for($counter = 0; $counter < $num_elmnts_array; $counter++){
$your_menu .= "<option value=\"$your_array[$counter]\">$your_array[$counter]        </option>";
//$counter++;
}
//end select menu
$your_menu .= "</select>";
?>

<p><b><?php echo "$your_menu"; ?></b><br>
<p id="pasteTheValue"></p>
现在,您的任务可以按如下所示完成:

$("#myDropDown").change(function(){
   var selectedValue = $(this).val();
   $("#pasteTheValue").val(selectedValue);
});

将下拉列表元素id视为myDropDown
//open the file
$read_your_file = @fopen($your_file, "r") or die ("Couldn't Access $your_file");

//create a variable to hold the contents of the file
$contents_your_file = fread($read_your_file, filesize($your_file));

//array of file contents
$your_array = explode("\n",$contents_your_file);

//close the file
fclose($read_your_file);

//counts the number elements in the property_categories array
$num_elmnts_array = count($your_array) ;

//elements in the drop down list
//$drop_elmnts = 0;

//begin creating your dropdown menu...

$your_menu = "<select name=\"list\" onchange=\"getSelectedValue(this.value)\">";  
//For loop to begin
for($counter = 0; $counter < $num_elmnts_array; $counter++){
$your_menu .= "<option value=\"$your_array[$counter]\">$your_array[$counter]        </option>";
//$counter++;
}
//end select menu
$your_menu .= "</select>";
?>

<p><b><?php echo "$your_menu"; ?></b><br>
<p id="pasteTheValue"></p>
现在,您的任务可以按如下所示完成:

$("#myDropDown").change(function(){
   var selectedValue = $(this).val();
   $("#pasteTheValue").val(selectedValue);
});

将下拉列表元素id视为myDropDown
//open the file
$read_your_file = @fopen($your_file, "r") or die ("Couldn't Access $your_file");

//create a variable to hold the contents of the file
$contents_your_file = fread($read_your_file, filesize($your_file));

//array of file contents
$your_array = explode("\n",$contents_your_file);

//close the file
fclose($read_your_file);

//counts the number elements in the property_categories array
$num_elmnts_array = count($your_array) ;

//elements in the drop down list
//$drop_elmnts = 0;

//begin creating your dropdown menu...

$your_menu = "<select name=\"list\" onchange=\"getSelectedValue(this.value)\">";  
//For loop to begin
for($counter = 0; $counter < $num_elmnts_array; $counter++){
$your_menu .= "<option value=\"$your_array[$counter]\">$your_array[$counter]        </option>";
//$counter++;
}
//end select menu
$your_menu .= "</select>";
?>

<p><b><?php echo "$your_menu"; ?></b><br>
<p id="pasteTheValue"></p>
现在,您的任务可以按如下所示完成:

$("#myDropDown").change(function(){
   var selectedValue = $(this).val();
   $("#pasteTheValue").val(selectedValue);
});
希望会有所帮助

$(document).ready(function(){
    $('select').change(function(){
       alert($(this).val()); 
    });
});
希望会有所帮助

$(document).ready(function(){
    $('select').change(function(){
       alert($(this).val()); 
    });
});
希望会有所帮助

$(document).ready(function(){
    $('select').change(function(){
       alert($(this).val()); 
    });
});
希望会有所帮助

$(document).ready(function(){
    $('select').change(function(){
       alert($(this).val()); 
    });
});
这个jsbin应该对你有帮助


清单1
清单2
清单3
清单4
已选择功能显示(thisObj)
{
document.getElementById('show')。value=thisObj.options[thisObj.selectedIndex]。文本;
}
如果您可以使用jquery,那么它应该会更简单

这个jsbin应该会帮助您


清单1
清单2
清单3
清单4
已选择功能显示(thisObj)
{
document.getElementById('show')。value=thisObj.options[thisObj.selectedIndex]。文本;
}
如果您可以使用jquery,那么它应该会更简单

这个jsbin应该会帮助您


清单1
清单2
清单3
清单4
已选择功能显示(thisObj)
{
document.getElementById('show')。value=thisObj.options[thisObj.selectedIndex]。文本;
}
如果您可以使用jquery,那么它应该会更简单

这个jsbin应该会帮助您


清单1
清单2
清单3
清单4
已选择功能显示(thisObj)
{
document.getElementById('show')。value=thisObj.options[thisObj.selectedIndex]。文本;
}

如果您可以使用jquery,那么将所选值从
列表框插入到
p
标记中应该会更加容易,如果您想在
文本框内插入该值,请使用此代码-

<input type="text" id="textboxid" value="" />

您正在将所选值从
列表框
插入到
p
标记中,如果要将该值插入
文本框
中,请使用此代码-

<input type="text" id="textboxid" value="" />

您正在将所选值从
列表框
插入到
p
标记中,如果要将该值插入
文本框
中,请使用此代码-

<input type="text" id="textboxid" value="" />

您正在将所选值从
列表框
插入到
p
标记中,如果要将该值插入
文本框
中,请使用此代码-

<input type="text" id="textboxid" value="" />
试试这个

$(document).ready(function(){
    document.getElementByID('listID').on('change',function(){
        var list  = document.getElementByID('listID');
        var indx = list.selectedIndex;
        document.getElementByID('otherFieldID').val(list[indx].text);
    });
});
试试这个

$(document).ready(function(){
    document.getElementByID('listID').on('change',function(){
        var list  = document.getElementByID('listID');
        var indx = list.selectedIndex;
        document.getElementByID('otherFieldID').val(list[indx].text);
    });
});
试试这个

$(document).ready(function(){
    document.getElementByID('listID').on('change',function(){
        var list  = document.getElementByID('listID');
        var indx = list.selectedIndex;
        document.getElementByID('otherFieldID').val(list[indx].text);
    });
});
试试这个

$(document).ready(function(){
    document.getElementByID('listID').on('change',function(){
        var list  = document.getElementByID('listID');
        var indx = list.selectedIndex;
        document.getElementByID('otherFieldID').val(list[indx].text);
    });
});


你想用jquery迭代你的选项吗,你能解释一下吗…@prabu试着用file_get_content代替fread你的文本框在代码中的什么位置?你想用jquery迭代你的选项吗,你能解释更多吗?…@prabu尝试用file_get_内容代替freadu在代码中的文本框在哪里?你想用jquery迭代你的选项吗?你能解释更多吗?…@prabu尝试用file_get_内容代替freadu在代码中的文本框在哪里?你想用jquery迭代你的选项吗,你能解释一下吗…@prabu试着用file_get_content代替freadu代码中的文本框在哪里?与我的答案有什么不同吗?没有,伙计,我在回答时没有检查任何答案:)与我的答案有什么不同吗?没有,伙计,我在回答时没有检查任何答案:)与m有什么不同吗