Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/88.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
Php 选择时清除文本框,选择时显示删除按钮_Php_Jquery_Html - Fatal编程技术网

Php 选择时清除文本框,选择时显示删除按钮

Php 选择时清除文本框,选择时显示删除按钮,php,jquery,html,Php,Jquery,Html,我有一个表单,用户使用它将信息保存到文本文件中,然后是一个下拉列表,它会将他们文件的名称拉回到文本字段中,但是我试图找出如何在选择一个值时清除文本字段。我有一个除了我的php之外添加新代码,它只是一个占位符,这样他们就可以使用表单来保存数据。我想弄清楚的是,当文本框选择特定的下拉列表时,如何清除它们。我还想添加一个删除按钮,每当从下拉列表中选择文件时,该按钮就会出现。下面是我的相关代码 感谢您对显示问题和css按钮的帮助,我现在正试图找出删除按钮删除当前选定文件的php脚本 <input

我有一个表单,用户使用它将信息保存到文本文件中,然后是一个下拉列表,它会将他们文件的名称拉回到文本字段中,但是我试图找出如何在选择一个值时清除文本字段。我有一个。基本上,我只是想有一个选项,让字段为空,这样他们就可以使用表单保存数据,然后在他们从下拉按钮选择数据时查看数据。我想用一个简单的jquery按钮来清除表单就可以了,这样我就不用担心这个按钮了;但是当我在JS中输入时,它说不能读取null属性,当然,在下拉选择中不会出现任何让删除按钮出现的情况。我输入的Javascript是document.getElementById'b1'.style.display='block';
< option value="0" >(Add New Code)< /option >
var ndx = document.getElementById('id').selectedIndex;

document.getElementById('id').options[ndx].text='';
$("#id option:selected").index()
$("#id[ndx]").text();
<button  type="button" id="b1" class="hide">Delete</button>
.hide{display:none;}
document.getElementById('b1').style.display='block';
<!DOCTYPE html>
<html lang="en"><head><title>Unhide Delete</title>
<style type="text/css">
.hide{display:none;}
</style></head><body>
<button  type="button" id="b1" class="hide">Delete</button>
<script type="text/javascript">
//<![CDATA[
document.getElementById('b1').style.display='block';
//]]>
</script></body></html>
<!DOCTYPE html>
<html lang="en"><head><title>Unhide Delete</title>
<style type="text/css">
.hide{display:none;}
</style></head><body>
<button  type="button"  onclick="hideShow()">Show Hide Delete</button><br/> <br/>
<button  type="button" id="b1" class="hide">Delete</button>
<script type="text/javascript">
//<![CDATA[
var toggle = new Array();
toggle['none'] = 'block';
toggle['block'] = 'none';
var del = document.getElementById('b1');
del.style.display='block';
function hideShow(){
del.style.display=toggle[del.style.display];
}
//]]>
</script></body></html>
<?php ob_start("ob_gzhandler");
header('Content-Type: text/html; charset=utf-8');
header('Connection: Keep-Alive');
header('Keep-Alive: timeout=5, max=100');
header('Cache-Control: max-age=120');
echo <<<EOT
<!DOCTYPE html>
<html lang="en"><head><title>Code</title>
<style type="text/css">
#CodeValue{width:50%;background:#eff; width:80%;font:400 1em "Courier New", Courier, monospace;overflow:scroll;} 
.btn{width:50%;margin:0 0 .5em 0;border-radius: 3px 3px 3px 3px;font: 700 1.2em Arial,Helvetica,Calibri,sans-serif;overflow: visible;border:1px solid #00f;color: #fff;padding: .1em;
background-image: -o-linear-gradient(bottom, #2ef 0%, #02f 100%);
background-image: -moz-linear-gradient(bottom, #2ef 0%, #02f 100%);
background-image: -webkit-linear-gradient(bottom, #2ef 0%, #02f 100%);
background-image: -ms-linear-gradient(bottom, #2ef 0%, #02f 100%);
background-image: linear-gradient(to bottom, #2ef 0%, #02f 100%);}
</style>
</head><body>
EOT;
ob_flush();
$ndx = 1;
$js = "var contents=new Array();\ncontents[0] = '';\n";
$directory = 'users/';
$files = scandir($directory) ;
$options = "<option></option>\n";
foreach( $files as $file ){
  if ( !is_dir($file) ){

    if(pathinfo($file,PATHINFO_EXTENSION) == 'php' ){
      $options .= "<option>$file</option>\n";
      $contents = file_get_contents($directory . $file);
      $contents = preg_replace('/</','&lt;',$contents);
      $contents = preg_replace('/>/','&gt;',$contents);
      $contents = preg_replace('/\n/','<br>',$contents);
      $contents = addslashes( $contents);
      $js .= "contents[$ndx] = \"$contents\"\n";
      $ndx++;
    }
  }
}
echo <<<EOT
<input type="hidden" name="Action" value="EDIT" /><input type="hidden" name="Selection"  id="Selection" value="-1"><div>Below is the list of your saved codes. To edit your codes, select it from the list.</div>
<select size="1" name="CodeList" id="CodeList" onchange="CodeChange();">
$options
</select> 
<h3>Saved Codes</h3>
<form method="post" action="/evo/avsaveprocess.php"><div>
<input type="hidden" name="Action" value="SAVE" />
<input type="hidden" name="CodeId" id="CodeId" value="0" />
<label>Description:</label>
<input type="text" name="CodeDescription" size="40" maxlength="50" id="CodeName" value="" /><br/>
<textarea rows="10" name="Code" id="CodeValue" onload="resize()">
</textarea><br/>
<input class="btn" type="submit" value="Save" />
</div></form>
<script type="text/javascript">
//<![CDATA[
$js
sel = document.getElementById('CodeList');
txt = document.getElementById('CodeValue');
var maxHeight = (window.innerHeight - txt.offsetTop) - 40;
function CodeChange(){
txt.style.height =  '100px';
var ndx = sel.selectedIndex; 
var temp = contents[ndx].replace(/&lt;/g,'<');
temp = temp.replace(/&gt;/g,'>');
txt.value= temp.replace(/<br>/g,"\\n");
var h = txt.scrollHeight;
if(h > maxHeight){h = maxHeight;}
txt.style.height = h + 'px';
}
//]]>
</script></body></html>
EOT;
ob_end_flush();