深入探讨PHP下拉框选择的实现方法_PHP教程
php
下拉
实现
探讨
提交
方法
深入
的
触发
选择
实现
第一种PHP下拉框实现方法:
- ?php
- //提交下拉框;
- //直接饱触发onchange事件的结果
-
$id=$_GET['myselect']; // myselect
为location.herf?id的名字; - echo $id;
- //用表单提交的结果;
- if($_POST["sendSelect"]){ //sendSelect 为表单的名字;
- $select_val=$_POST["selectID"];
- echo "你选择的值为: $select_val";
- }
- // print_r($_POST);
- $xing="xing";
- $fang="fang";
-
echo ' a href=del_03.php?id='.$xing.'
&action='.$fang.'>flx /a>'; - //php中,在删除内容时,给的提示的写法; href 后面必须加引号;
-
echo "n"." input type='button'
value='删除' onclick="if(confirm('确定要删除吗'))
{ location.href='?delete=$result_manage[p_id]'}"> - br> br>";
- }
-
echo " input type='button' value='connect_next'
onclick="location.href='del_03.php?id=
$xing&action=$fang'">"; - ?>
第二种PHP下拉框选择实现方法:
<ol class="dp-xml"> <li class="alt"><span><span class="tag"><span> </span><span class="tag-name">input</span><span> </span><span class="attribute">type</span><span>=</span><span class="attribute-value">"button"</span><span> </span><span class="attribute">value</span><span>=</span><span class="attribute-value">"delete"</span><span> </span><span class="attribute">onclick</span><span>=</span><span class="attribute-value">"<br>if(confirm('确定要删除吗')) location.href=<br>'del_03.php?id=xing'"</span><span class="tag">></span><span class="tag"><span> </span><span class="tag-name">br</span><span class="tag">/></span><span> </span></span></span></span></li> <li><span class="tag"><span> </span><span class="tag-name">script</span><span> </span><span class="attribute">language</span><span>=</span><span class="attribute-value">"JavaScript"</span><span> </span><span class="attribute">type</span><span>=</span><span class="attribute-value">"text/javascript"</span><span class="tag">></span><span> </span></span></li> <li class="alt"><span>function select(obj){ </span></li> <li> <span class="attribute">window.location.href</span><span>=</span><span class="attribute-value">'del_04.php?myselect=<br>'</span><span>+obj.options[obj.selectedIndex].value; </span> </li> <li class="alt"><span>return; //可以不写; </span></li> <li><span>} </span></li> <li class="alt"><span class="tag"><span> /script</span><span class="tag">></span><span> </span></span></li> <li><span class="tag"><span> </span><span class="tag-name">input</span><span> </span><span class="attribute">type</span><span>=</span><span class="attribute-value">"button"</span><span> </span><span class="attribute">value</span><span>=</span><span class="attribute-value">"delete"</span><span> <br></span><span class="attribute">onclick</span><span>=</span><span class="attribute-value">"if(confirm('确定要删除吗')) <br>location.href='del_03.php?id=xing'"</span><span class="tag">></span><span class="tag"><span> </span><span class="tag-name">br</span><span class="tag">/></span><span> </span></span></span></li> <li class="alt"><span class="tag"><span> </span><span class="tag-name">form</span><span> </span><span class="attribute">name</span><span>=</span><span class="attribute-value">"myform"</span><span> </span><span class="attribute">action</span><span>=</span><span class="attribute-value">"del_04.php"</span><span> <br></span><span class="attribute">method</span><span>=</span><span class="attribute-value">"post"</span><span class="tag">></span><span> </span></span></li> <li><span class="tag"><span> !-- 直接触发onchange 事件 ,此时不用提交表单,-- </span><span class="tag">></span><span> </span></span></li> <li class="alt"><span class="tag"><span> !--</span><span class="tag"><span> </span><span class="tag-name">select</span><span> </span><span class="attribute">name</span><span>=</span><span class="attribute-value">"selectID"</span><span> </span><span class="attribute">onchange</span><span>=<br></span><span class="attribute-value">"location='del_04.php?myselect='+this.options<br>[this.selectedIndex].value"</span><span class="tag">></span><span>--</span><span class="tag">></span><span> </span></span></span></li> <li><span class="tag"><span> !-- 把onchange 的事件写在一个函数里面-- </span><span class="tag">></span><span> </span></span></li> <li class="alt"><span class="tag"><span> </span><span class="tag-name">select</span><span> </span><span class="attribute">name</span><span>=</span><span class="attribute-value">"selectID"</span><span> </span><span class="attribute">onchange</span><span>=</span><span class="attribute-value">"select(this)"</span><span class="tag">></span><span> </span></span></li> <li><span class="tag"><span> !-- </span><span class="tag"><span> </span><span class="tag-name">select</span><span> </span><span class="attribute">name</span><span>=</span><span class="attribute-value">"selectID"</span><span> </span><span class="tag">></span><span>--</span><span class="tag">></span><span> </span></span></span></li> <li class="alt"><span class="tag"><span> </span><span class="tag-name">option</span><span> </span><span class="attribute">value</span><span>=</span><span class="attribute-value">"0"</span><span class="tag">></span><span>请选择</span><span class="tag"><span> /option</span><span class="tag">></span><span> </span></span></span></li> <li><span class="tag"><span> </span><span class="tag-name">option</span><span> </span><span class="attribute">value</span><span>=</span><span class="attribute-value">"value1"</span><span class="tag">></span><span>option1</span><span class="tag"><span> /option</span><span class="tag">></span><span> </span></span></span></li> <li class="alt"><span class="tag"><span> </span><span class="tag-name">option</span><span> </span><span class="attribute">value</span><span>=</span><span class="attribute-value">"value2"</span><span class="tag">></span><span>option2</span><span class="tag"><span> /option</span><span class="tag">></span><span> </span></span></span></li> <li><span class="tag"><span> </span><span class="tag-name">option</span><span> </span><span class="attribute">value</span><span>=</span><span class="attribute-value">"value3"</span><span class="tag">></span><span>option3</span><span class="tag"><span> /option</span><span class="tag">></span><span> </span></span></span></li> <li class="alt"><span class="tag"><span> /select</span><span class="tag">></span><span> </span></span></li> <li><span class="tag"><span> </span><span class="tag-name">input</span><span> </span><span class="attribute">type</span><span>=</span><span class="attribute-value">"submit"</span><span> </span><span class="attribute">name</span><span>=</span><span class="attribute-value">"sendSelect"</span><span> <br></span><span class="attribute">value</span><span>=</span><span class="attribute-value">"提交下拉框"</span><span class="tag">/></span><span> </span></span></li> <li class="alt"><span class="tag"><span> /form</span><span class="tag">></span><span> </span></span></li> </ol>
登录后复制
以上就是PHP下拉框的两种实现方法介绍。
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章
R.E.P.O.能量晶体解释及其做什么(黄色晶体)
2 周前
By 尊渡假赌尊渡假赌尊渡假赌
仓库:如何复兴队友
1 个月前
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island冒险:如何获得巨型种子
4 周前
By 尊渡假赌尊渡假赌尊渡假赌
击败分裂小说需要多长时间?
3 周前
By DDD
R.E.P.O.保存文件位置:在哪里以及如何保护它?
3 周前
By DDD

热工具

记事本++7.3.1
好用且免费的代码编辑器

SublimeText3汉化版
中文版,非常好用

禅工作室 13.0.1
功能强大的PHP集成开发环境

Dreamweaver CS6
视觉化网页开发工具

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)

PHP 8.4 带来了多项新功能、安全性改进和性能改进,同时弃用和删除了大量功能。 本指南介绍了如何在 Ubuntu、Debian 或其衍生版本上安装 PHP 8.4 或升级到 PHP 8.4

CakePHP 是 PHP 的开源框架。它的目的是使应用程序的开发、部署和维护变得更加容易。 CakePHP 基于类似 MVC 的架构,功能强大且易于掌握。模型、视图和控制器 gu

Visual Studio Code,也称为 VS Code,是一个免费的源代码编辑器 - 或集成开发环境 (IDE) - 可用于所有主要操作系统。 VS Code 拥有针对多种编程语言的大量扩展,可以轻松编写
