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:
- <? Php
- // Submit the drop-down list;
- // The result of triggering the onchange event
- $ Id = $ _ GET ['myselect']; // myselect
Is location. herf? Id;
- Echo $ id;
- // Results submitted using forms;
- If ($ _ POST ["sendSelect"]) {// sendSelect indicates the form name;
- $ Select_val = $ _ POST ["selectID"];
- Echo "the value you selected is $ select_val ";
- }
- // Print_r ($ _ POST );
- $ Xing = "xing ";
- $ Fang = "fang ";
- Echo'< AHref = del_03.php? Id = '. $ xing .'
& Action = '. $ fang .'>Flx</>';
- // In php, when the content is deleted, the prompt is written; href must be followed by quotation marks;
- Echo "n "."< InputType = 'Button'
Value = 'delete 'onclick = "if (confirm ('Are you sure you want to delete it '))
{Location. href = '? Delete = $ result_manage [p_id] '}">
- < Br> < Br>";
- }
- Echo"< InputType = 'Button 'value = 'connect _ next'
Onclick = "location. href = 'Del _ 03.php? Id =
$ Xing & action = $ fang '">";
- ?>
The second PHP drop-down box selects the implementation method:
- <Input type = "button" value = "delete" onclick ="
If (confirm ('Are you sure you want to delete ') location. href =
'Del _ 03.php? Id = xing '"> <br/>
- <Script language = "JavaScript" type = "text/javascript">
- Function select (obj ){
- Window. location. href = 'Del _ 04.php? Myselect =
'+ Obj. options [obj. selectedIndex]. value;
- Return; // do not write;
- }
- </Script>
- <Input type = "button" value = "delete"
Onclick = "if (confirm ('Are you sure you want to delete it '))
Location. href = 'Del _ 03.php? Id = xing '"> <br/>
- <Form name = "myform" action = "del_04.php"
Method = "post">
- <! -- Triggers the onchange event directly. you do not need to submit a form at this time. -->
- <! -- <Select name = "selectID" onchange =
"Location = 'Del _ 04.php? Myselect = '+ this. options
[This. selectedIndex]. value "> -->
- <! -- Write the onchange event in a function -->
- <Select name = "selectID" onchange = "select (this)">
- <! -- <Select name = "selectID"> -->
- <Option value = "0"> select </option>
- <Option value = "value1"> option1 </option>
- <Option value = "value2"> option2 </option>
- <Option value = "value3"> option3 </option>
- </Select>
- <Input type = "submit" name = "sendSelect"
Value = "submit a drop-down list"/>
- </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...