In-depth discussion of PHP drop-down box selection implementation method _ PHP Tutorial

Source: Internet
Author: User
In-depth discussion on the implementation of PHP drop-down box selection. Implementation of the first PHP drop-down box :? Php submits a drop-down box. the result of triggering the onchange event is $ id $ _ GET [myselect]. myselect is location. herf? Id; echo $ I implementation

The first PHP drop-down box implementation method:

  1. <? Php
  2. // Submit the drop-down list;
  3. // The result of triggering the onchange event
  4. $ Id = $ _ GET ['myselect']; // myselect
    Is location. herf? Id;
  5. Echo $ id;
  6. // Results submitted using forms;
  7. If ($ _ POST ["sendSelect"]) {// sendSelect indicates the form name;
  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. Echo'< AHref = del_03.php? Id = '. $ xing .'
    & Action = '. $ fang .'>Flx</>';
  15. // In php, when the content is deleted, the prompt is written; href must be followed by quotation marks;
  16. Echo "n "."< InputType = 'Button'
    Value = 'delete 'onclick = "if (confirm ('Are you sure you want to delete it '))
    {Location. href = '? Delete = $ result_manage [p_id] '}">
  17. < Br> < Br>";
  18. }
  19. Echo"< InputType = 'Button 'value = 'connect _ next'
    Onclick = "location. href = 'Del _ 03.php? Id =
    $ Xing & action = $ fang '">";
  20. ?>

The second PHP drop-down box selects the implementation method:

 
  1. <Input type = "button" value = "delete" onclick ="
    If (confirm ('Are you sure you want to delete ') 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; // do not write;
  6. }
  7. </Script>
  8. <Input type = "button" value = "delete"
    Onclick = "if (confirm ('Are you sure you want to delete it '))
    Location. href = 'Del _ 03.php? Id = xing '"> <br/>
  9. <Form name = "myform" action = "del_04.php"
    Method = "post">
  10. <! -- Triggers the onchange event directly. you do not need to submit a form at this time. -->
  11. <! -- <Select name = "selectID" onchange =
    "Location = 'Del _ 04.php? Myselect = '+ this. options
    [This. selectedIndex]. value "> -->
  12. <! -- Write the onchange event in a function -->
  13. <Select name = "selectID" onchange = "select (this)">
  14. <! -- <Select name = "selectID"> -->
  15. <Option value = "0"> select </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 = "submit a drop-down list"/>
  21. </Form>

The above are two implementation methods in the PHP drop-down box.


Compile the first PHP drop-down box implementation method :? Php // submit the drop-down box; // the result of triggering the onchange event directly $ id = $ _ GET ['myselect']; // myselect is location. herf? Id; echo $ I...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.