当前位置:编程学习 > JS >>

js给select动态增加数据并由php接受保存到数据

网页特效给select动态增加数据并由php教程接受保存到数据

<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.zzzyk.com/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
<title>网页特效给select动态增加数据并由php接受保存到数据</title>
 <script language="网页特效">
  function onclickadd(id,cityname,obj)
  {   
   var opt = new option(cityname,id);
   obj.options.add(opt);     
   var c = obj.options.length-1;     
   obj.options[c].selected=true; 
  }  
 </script>
</head>

<body>
<form id="form1" name="form1" method="post" action="">
  <select name="select1" id="select">
    <option value="1">值一</option>
  </select>
  <input type="button" name="button2"  value="增加"  onclick="onclickadd('1000-2000','1000-2000',select1);"/>
 
<input type="submit" name="button" id="button" value="提交" />
</form>
</body>
</html>

 

<?
if( $_post )
{
 $value = $_post['select'];
    echo $value;
    保存数据库教程操作
}
?>

 

补充:网页制作,js教程 
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,