<!DOCTYPE html PUBLIC
“-//W3C//DTD XHTML 1.0 Transitional//EN”
“;
<html xmlns=”;
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=gb2312″
/>
<title>php外部变量</title>
</head>

实例一:

php把文本框回车转换成html换行

<body>
<?php
$user=$_POST[‘user’];
echo “姓名;$User[name]<br>n”;
echo “姓别;$User[sex]<br>n”;
echo “邮箱;$User[email]<br>n”
?>
</body>
</html>澳门新葡萄京官网注册 1

 

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”
“”>
<html xmlns=””>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=gb2312″
/>
<title>无标题文档</title>
</head>

这是我定义6.php页面

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”
“;

<body>
<form id=”form1″ name=”form1″ method=”post” action=””>
  <label>
  <textarea name=”t” id=”t” cols=”45″ rows=”5″></textarea>
  </label>
  <label>
  <input type=”submit” name=”button” id=”button” value=”提交” />
  </label>
</form>
<?php
 if($_POST){
  echo str_replace(chr(13),'<br>’,$_POST[‘t’]);
 }
 ?>
</body>
</html>

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0
Transitional//EN”
“;
<html xmlns=”;
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=gb2312″ />
<title>一个简单html表单</title>
</head>
<body>
<form action=”6.php”
method=”POST”>
    Name:  <input type=”text”
name=”User[name]”><br>
    Gender:男<input name=”User[sex]” type=”radio”
value=”男性” />
    女<input name=”User[sex]” type=”radio”
value=”女性” />
    <br />
  Email:
  <input type=”text”
name=”User[email]”><br>
    <input type=”submit”value=”Submit
me!”>
</form>

<html xmlns=”;

</body>

<head>

</html>澳门新葡萄京官网注册 2

<meta http-equiv=”Content-Type” content=”text/html; charset=gb2312″
/>

这是编程难点,我想写进日志,回过头看看。

<title>无标题文档</title>

澳门新葡萄京官网注册 3

<script type=”text/javascript”  src=”jquery-1.8.1.js”>

6.php

</script>

澳门新葡萄京官网注册 4

<script type=”text/javascript”>

6.html

 $(function(){

  /*

  var p = $(“p”);

  var li = $(“ul li:eq(1)”);

 

  var title = p.attr(“title”);

  var title2 = li.attr(“title”);

  var text = li.text();

 

  alert(title);//hello world

  alert(title2);//1

  alert(text);//好

  */

  /*

  $(“ul”).append(“<li title=’abc’>hello</li>”)

    .append(“<li title=’xyz’>world</li>”);

  */

  $(“<li title=’abc’>hello</li>”).appendTo(“ul”);

 });

</script>

</head>

 

<body>

<p title=”hello world”>你觉得学校怎么样?</p>

<ul>

 <li title=”o”>一般</li>

 <li title=”1″>好</li>

 <li title=”2″>很好</li>

 <li title=”3″>非常好</li>

 <li title=”4″>好得不得了</li>

 <li title=”5″>好的无法形容</li>

</ul>

</body>

</html>

 

 

 

 

 

实例二:

 

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”
“;

<html xmlns=”;

<head>

<meta http-equiv=”Content-Type” content=”text/html; charset=gb2312″
/>

<title>无标题文档</title>

<script type=”text/javascript”  src=”jquery-1.8.1.js”>

</script>

<script type=”text/javascript”>

 /*

 var addItems = function()

 {

  

  document.getElementById(“div1″).innerHTML=””;//避免重复点击

  var value = parseInt(document.getElementById(“itemsNumber”).value);

  //alert(value);

  for(var i = 0; i < value; i++)

  {

   var input = document.createElement(“input”);

   input.setAttribute(“type”,”text”);

 

   var br = document.createElement(“br”);

   

   document.getElementById(“div1”).appendChild(input);

   document.getElementById(“div1”).appendChild(br);

  }

 }

 */

 $(function(){

  $(“#btn”).click(function(){

   document.getElementById(“div1″).innerHTML=””;

   var value = parseInt($(“#itemsNumber”).val());

   

   for(var i = 0; i < value; i++)

   {

    $(“#div1”).append(“<input type=’text’><br>”);

   }

  });

 });

 

</script>

</head>

 

<body>

<input type=”text” id=”itemsNumber”>

<input type=”button” id=”btn” value=”click”>

<div id=”div1″></div>

</body>

</html>

 

 

 

实例三:

 

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”
“;

<html xmlns=”;

<head>

<meta http-equiv=”Content-Type” content=”text/html; charset=gb2312″
/>

<title>无标题文档</title>

<script type=”text/javascript”  src=”jquery-1.8.1.js”>

</script>

<script type=”text/javascript”>

 $(function(){

  var li1 = “<li title=’hello’>hello1</li>”;

  var li2 = “<li title=’hello’>hello2</li>”;

  var li3 = “<li title=’hello’>hello3</li>”;

 

  $(“ul”).append(li1);

  $(“ul”).prepend(li2);

  $(“ul li:eq(4)”).after(li3);

 });

</script>

</head>

 

<body>

<p title=”hello world”>你觉得学校怎么样?</p>

<ul>

 <li title=”o”>一般</li>

 <li title=”1″>好</li>

 <li title=”2″>很好</li>

 <li title=”3″>非常好</li>

 <li title=”4″>好得不得了</li>

 <li title=”5″>好的无法形容</li>

</ul>

</body>

</html>

 

 

 

运行结果:

 

澳门新葡萄京官网注册 5

 

 

 

实例四:

 

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”
“;

<html xmlns=”;

<head>

<meta http-equiv=”Content-Type” content=”text/html; charset=gb2312″
/>

<title>无标题文档</title>

<script type=”text/javascript”  src=”jquery-1.8.1.js”>

</script>

<script type=”text/javascript”>

 $(function(){

  $(“ul li:eq(2)”).insertAfter(“ul li:eq(4)”);

 });

</script>

</head>

 

<body>

<p title=”hello world”>你觉得学校怎么样?</p>

<ul>

 <li title=”o”>一般</li>

 <li title=”1″>好</li>

 <li title=”2″>很好</li>

 <li title=”3″>非常好</li>

 <li title=”4″>好得不得了</li>

 <li title=”5″>好的无法形容</li>

</ul>

</body>

</html>

 

 

 

 

 

实例五:

 

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”
“;

<html xmlns=”;

<head>

<meta http-equiv=”Content-Type” content=”text/html; charset=gb2312″
/>

<title>无标题文档</title>

<script type=”text/javascript”  src=”jquery-1.8.1.js”>

</script>

<script type=”text/javascript”>

 $(function(){

  //remove()方法返回被移除的节点的jQuery对象

  var removedLi = $(“ul li:eq(3)”).remove();

  removedLi.appendTo($(“ul”));

 

  $(“ul li”).remove(“li[title = 2]”);

 

  $(“ul li:eq(3)”).empty();

 });

</script>

</head>

 

<body>

<p title=”hello world”>你觉得学校怎么样?</p>

<ul>

 <li title=”o”>一般</li>

 <li title=”1″>好</li>

 <li title=”2″>很好</li>

 <li title=”3″>非常好</li>

 <li title=”4″>好得不得了</li>

 <li title=”5″>好的无法形容</li>

</ul>

</body>

</html>

 

 

 

运行结果:

 

 

澳门新葡萄京官网注册 6

 

 

 

 

实例六:动态文件添加和删除

 

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”
“;

<html xmlns=”;

<head>

<meta http-equiv=”Content-Type” content=”text/html; charset=gb2312″
/>

<title>无标题文档</title>

<script type=”text/javascript”  src=”jquery-1.8.1.js”>

</script>

<script type=”text/javascript”>

 /*

 function addFile()

 {

  var div = document.getElementById(“file”);

 

  var br = document.createElement(“br”);

  var input = document.createElement(“input”);

  var btn = document.createElement(“input”);

 

  input.setAttribute(“type”,”file”);

  btn.setAttribute(“type”,”button”);

  btn.setAttribute(“value”,”删除”);

 

  btn.onclick = function(){

   div.removeChild(br);

   div.removeChild(input);

   div.removeChild(btn);

  }

 

  div.appendChild(br);

  div.appendChild(input);

  div.appendChild(btn);

 }

 */

 $(function(){

  $(“#addFile”).click(function(){

   var br = $(“<br/>”);

   var input = $(“<input type=’file’>”);

   var btn = $(“<input type=’button’ value=’删除’>”);

   $(“#file”).append(br).append(input).append(btn);

   btn.click(function(){

    br.remove();

    input.remove();

    btn.remove();

   });

  });

 });

</script>

</head>

 

<body>

<input type=”button” value=”添加” id=”addFile”>

<div id=”file”></div>

</body>

</html>

 

 

 

结果如下:

 

澳门新葡萄京官网注册 7

 

 

 

实例七:

 

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”
“;

<html xmlns=”;

<head>

<meta http-equiv=”Content-Type” content=”text/html; charset=gb2312″
/>

<title>无标题文档</title>

<script type=”text/javascript”  src=”jquery-1.8.1.js”>

</script>

<script type=”text/javascript”>

 $(function(){

  $(“#username”).focus(function(){

   var value = $(this).val();

   if(value == this.defaultValue)

   {

    $(this).val(“”);

   }

  });

  $(“#username”).blur(function(){

   var value = $(this).val();

   if(value == “”)

   {

    $(this).val(this.defaultValue);

   }

  });

 });

</script>

</head>

 

<body>

<input type=”text” id=”username” value=”用户名”/><br>

<input type=”password” id=”password”/><br>

<input type=”button” value=”确定”>

</body>

</html>

!DOCTYPE html PUBLIC -//W3C//DTD XHTML
1.0 Transitional//EN
html
xmlns= head meta ht…