如何在同一页面上显示所选值
How to display selected value on same page
这是我的代码
<?
$your_file = "tmp1.txt";
//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'">";
//For loop to begin
for($counter = 0; $counter < $num_elmnts_array; $counter++){
$your_menu .= "<option value='"$your_variable'">$your_array[$counter]</option>";
//$counter++;
}
//end select menu
$your_menu .= "</select>";
?>
<p><b>Here is my Menu</b><br>
<? echo "$your_menu";
?>
这段代码帮助在html列表框中列出文本文件中的单词。我对所选值的显示有疑问。它的输出只是显示一个选择框,其中包含文本文件中的单词。现在我想显示选定的单词。如果我从列表框中选择了选项,那么我可以在每个单词上显示和分配任务。
请帮助我在同一页中显示选定的单词。或者另一个页面(post方法)
you are looking like this:
<script>
function getSelectedValue(theValue){
document.getElementById('pasteTheValue').innerHTML=theValue;
}
</script>
<?php
$your_file = "file.txt";
//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>
相关文章:
- 使用Booklet Jquery插件,我如何验证最后一页是否显示
- Javascript并不是显示在每一页上
- 如何在一页上显示多个Highcharts图表
- 一页主题搜索/用下一个按钮突出显示文本
- 当一次加载所有文件时,是否有来自阵列的10个随机闪存文件显示在页面上?(在javascript中)
- Angularjs:目录分页控件没有'即使按下页面按钮,也不会显示下一页
- 在表单提交后显示模态,直到加载下一页为止..不适用于狩猎
- 无法在一页上显示多个Highchart
- 计算文本字段的数量&在另一页中显示总数
- 当我们选择页面中的文本框时,在选择该chk框时在另一页中显示一些文本
- 如何在另一页上显示地图并全屏查看
- 有没有什么方法可以避免在谷歌可视化图表的图例中分页,并在一页中用两行显示所有行
- 如何在重定向到另一页之前显示正在加载的图像
- 当点击rails中的提交按钮时,如何在重定向到下一页之前显示模态
- 要显示在另一页上的表单信息
- 在iFrame中显示用户上一页
- 当用户点击链接到下一页的项目时,我如何在网页中显示加载
- jquery Mobile->页面显示,但下一页没有't
- 纵向屏幕有2页,但只能显示其中一页
- 是否有一种方法来显示同一页上的内容后,一个按钮被点击