简体   繁体   中英

Selecting table from drop down list using php

Hey guys just wondering how i go about using a drop down list to show different php tables? The divs are currently set to hidden but when i do select a table from drop down list and press submit i want it to come up ( div is called fixtures )... please help

<?php if(isset($_POST["submit"])) {


  if($_POST['chooseoptions'] =='form2') {
  // show fixtures table
  }
  elseif($_POST['chooseoptions'] == 'form3') {
  // change current round number
  }
 elseif($_POST['chooseoptions'] == 'form4') {
 // update user tips
 }
 elseif($_POST['chooseoptions'] == 'form5') {
// reset
} 
 } ?>

<html>
<body>

<form name="work" id="work"  action="POSTBACK" >

<input type="submit" name="submit" value="submit">

<p>Select Table:
<select name="chooseoptions" id="chooseoptions" >
<option value="blank"> </option>
    <option value="form2">Form 2 : Display tip table</option>
<option value="form3">Form 3 : Change rounds</option>
<option value="form4">Form 4 : Update table/option>
<option value="form5">Form 5 : RESET</option>
</select></p>

<div id="fixtures" name="fixtures" style='display: none'>
</div
</body>
</html>

See example below: Evaluate with PHP and print based on the result.

Adding the class will probably help. On clientside you can control the div with using css. In the example you can use the classes for enabled once:

.fix-enable{} 

and for the disabled one

.fix-disable{
    //for example disabled
    display:none;
}


    <html>
    <body>

    <form name="work" id="work"  action="POSTBACK" >

        <input type="submit" name="submit" value="submit">

        <p>Select Table:
        <select name="chooseoptions" id="chooseoptions" >
            <option value="blank"> </option>
            <option value="form2">Form 2 : Display tip table</option>
            <option value="form3">Form 3 : Change rounds</option>
            <option value="form4">Form 4 : Update table/option>
            <option value="form5">Form 5 : RESET</option>
        </select>
        </p>
    </form>
    <?php 
    $classname = "fix-disable";
    if(!isset($_POST["submit"])) {
        $classname = "fix-enable";
    }?>
    <div id="fixtures" name="fixtures" class=<?=$classname?>>

    </div>
    </body>
    </html>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM