Answers for "php on select change"

PHP
1

php select page change

<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>
Posted by: Guest on January-05-2021
1

php select page change

<?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>
Posted by: Guest on January-05-2021
2

onchange on select tag

<select id="comboA" onchange="getComboA(this)">
  <option value="">Select combo</option>
  <option value="Value1">Text1</option>
  <option value="Value2">Text2</option>
  <option value="Value3">Text3</option>
</select>
Posted by: Guest on May-19-2020
5

js select on change value

document.getElementById('my-select').addEventListener('change', function() {
  console.log('You selected: ', this.value);
});
Posted by: Guest on May-14-2020

Browse Popular Code Answers by Language