“Modification de la page PHP SELECT” Réponses codées

Modification de la page PHP SELECT

<?php
$page = null;
if(isset($_POST['page'])){
    $page = $_POST['page'];
}
switch($page){
    case 'page3': include_once('/path/to/page3content.php'); break;
    case 'page2': include_once('/path/to/page2content.php'); break;
    case 'page1': include_once('/path/to/page1content.php'); break;
    default: include_once('/path/to/defaultcontent.php'); break;
}
?>
<form name="myform" action="" method="post">
    <select name="page" onchange="this.form.submit()">
        <option value="page1"<?php if($page == "page1"){ echo " selected"; }?>>Page 1</option>
        <option value="page2"<?php if($page == "page2"){ echo " selected"; }?>>Page 2</option>
        <option value="page3"<?php if($page == "page3"){ echo " selected"; }?>>Page 3</option>
    </select>
</form>
Busy Butterfly

Modification de la page PHP SELECT

<select name="page" onchange="window.location=this.value">
    <option value="/path/to/page1.php">Page 1</option>
    <option value="/path/to/page2.php">Page 2</option>
    <option value="/path/to/page3.php">Page 3</option>
</select>
Busy Butterfly

Modification de la page PHP SELECT

<?php
$page = null;
if(isset($_POST['page'])){
    $page = $_POST['page'];
}
switch($page){
    case 'page3': include_once('/path/to/page3content.php'); break;
    case 'page2': include_once('/path/to/page2content.php'); break;
    case 'page1': include_once('/path/to/page1content.php'); break;
    default: include_once('/path/to/defaultcontent.php'); break;
}
?>
<form name="myform" action="" method="post">
    <select name="page" onchange="this.form.submit()">
        <option value="page1"<?php if($page == "page1"){ echo " selected"; }?>>Page 1</option>
        <option value="page2"<?php if($page == "page2"){ echo " selected"; }?>>Page 2</option>
        <option value="page3"<?php if($page == "page3"){ echo " selected"; }?>>Page 3</option>
    </select>
</form>
Magsverge Solutions

Réponses similaires à “Modification de la page PHP SELECT”

Questions similaires à “Modification de la page PHP SELECT”

Plus de réponses similaires à “Modification de la page PHP SELECT” dans PHP

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code