In-depth discussion on the implementation method of PHP drop-down box selection_PHP tutorial

WBOY
Release: 2016-07-15 13:34:37
Original
1050 people have browsed it

Implementation

The first PHP drop-down box implementation method:

  1. < ?php
  2. / /Submit drop-down box;
  3. //Directly trigger the result of onchange event
  4. $id=$_GET['myselect']; // myselect
    is the name of location.herf?id;
  5. echo $id;
  6. //Results submitted using the form;
  7. if($_POST["sendSelect"]){ //sendSelect is the name of the form;
  8. $select_val=$_POST["selectID"];
  9. echo "The value you selected is: $select_val";
  10. }
  11. // print_r($_POST);
  12. $xing="xing";
  13. $fang="fang" ;
  14. a href=del_03.php?id='.$xing.' &action='.$fang.'
    >flx< /a>'; //In php, When deleting content, the prompt given is written; href must be followed by quotation marks; echo "n"."<
  15. input type='button' value= 'Delete'
    onclick="if(confirm('Confirm to delete ?')) { location.href='?delete=$result_manage[p_id]'}"
    > < br
  16. >< br>"; } echo "<
  17. input type='button' value='connect_next' onclick="location.href='del_03.php?id=
    $xing&action=$fang'
    "> ;";
  18. ?> >The second implementation method of PHP drop-down box selection:
  19. The above is an introduction to the two implementation methods of PHP drop-down box.

  1. < input type="button" value="delete" onclick="
    if(confirm('确定要删除吗')) location.href=
    'del_03.php?id=xing'"
    >< br/> 
  2. < script language="JavaScript" type="text/javascript"> 
  3. function select(obj){  
  4. window.location.href='del_04.php?myselect=
    '
    +obj.options[obj.selectedIndex].value;  
  5. return; //可以不写;  
  6. }  
  7. < /script> 
  8. < input type="button" value="delete"
    onclick="if(confirm('确定要删除吗'))
    location.href='del_03.php?id=xing'"
    >< br/> 
  9. < form name="myform" action="del_04.php"
    method="post"> 
  10. < !-- 直接触发onchange 事件 ,此时不用提交表单,-- > 
  11. < !--< select name="selectID" onchange=
    "location='del_04.php?myselect='+this.options
    [this.selectedIndex].value"
    >--> 
  12. < !-- 把onchange 的事件写在一个函数里面-- > 
  13. < select name="selectID" onchange="select(this)"> 
  14. < !-- < select name="selectID" >--> 
  15. < option value="0">请选择< /option> 
  16. < option value="value1">option1< /option> 
  17. < option value="value2">option2< /option> 
  18. < option value="value3">option3< /option> 
  19. < /select> 
  20. < input type="submit" name="sendSelect"
    value="提交下拉框"/> 
  21. < /form> 
http://www.bkjia.com/PHPjc/445968.html

www.bkjia.com
true

http: //www.bkjia.com/PHPjc/445968.htmlTechArticleImplement the first PHP drop-down box implementation method: ?php //Submit the drop-down box; //Directly trigger onchange The result of the event $ id =$_GET['myselect'];//myselect is the name of location.herf?id; echo$i...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!