Hello,

I have just created a new page of form submittion but wanted to show different form value when different option is selected from the dropdown can any please help me out with this concirn.

Here is my code

<form method="post" name="form2" action="insert_report.php">
<label>  
    <p><b>Campaign</b></p>
    <p>
        <select name="campaign">
            <option value="">Select Campaign</option>
            <option value="web">Karachi</option>
            <option value="logo">Lahore</option>
            <option value="graphic">Islamabad</option>
        </select>                            
    <p>
</label>

<label>  
    <?php
        switch ($_POST['campaign'])
        {
            case 'web':
                echo "<p><b>Web Status</b></p>";
                echo "<p><input type='text' name='stat' class='pw'></p>";
                echo "<p><b>Pages Develop</b></p>";
                echo "<p><input type='text' name='dev' class='pw'></p>";
                break;
            case 'logo':
                echo "<p><b>Logo Uploaded</b></p>";
                echo "<p><input type='text' name='logo1' class='pw'></p>";
                echo "<p><b>Revised Logo</b></p>";
                echo "<p><input type='text' name='logo2' class='pw'></p>";
                break;
            case 'graphic':
                echo "<p><b>Type Of Designs</b></p>";
                echo "<p><input type='text' name='tod' class='pw'></p>";
                echo "<p><b>Worked On Revisions</b></p>";
                echo "<p><input type='text' name='wor' class='pw'></p>";
                break;
            default:
                echo " ";
    }
    ?>
</label>

I hope you guyz will help me out with this concirn

Thank you

you should make use jquery. this is for example:
file a.php

<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <script type="text/javascript" src="assets/js/jquery-1.9.1.min.js"></script>
    <script type="text/javascript">
    var htmlobjek;
    $(document).ready(function(){
      $("#campaign").change(function(){
        var campaign = $("#campaign").val();
        $.ajax({
            url: "aget.php",
            data: "campaign="+campaign,
            cache: false,
            success: function(msg){
                $("#content").html(msg);
            }
        });
      });
    });

</script>
</head>
<body>
    <form method="post" name="form2" action="insert_report.php">
    <label>  
        <p><b>Campaign</b></p>
        <p>
        <select name="campaign" id="campaign">
            <option value="">Select Campaign</option>
            <option value="web">Karachi</option>
            <option value="logo">Lahore</option>
            <option value="graphic">Islamabad</option>
        </select>                            
    <p>
    </label>
    <label id="content">  

    </label>
    </form>
</body>
</html>

file aget.php

<?php
        switch ($_GET['campaign'])
        {
            case 'web':
                echo "<p><b>Web Status</b></p>";
                echo "<p><input type='text' name='stat' class='pw'></p>";
                echo "<p><b>Pages Develop</b></p>";
                echo "<p><input type='text' name='dev' class='pw'></p>";
                break;
            case 'logo':
                echo "<p><b>Logo Uploaded</b></p>";
                echo "<p><input type='text' name='logo1' class='pw'></p>";
                echo "<p><b>Revised Logo</b></p>";
                echo "<p><input type='text' name='logo2' class='pw'></p>";
                break;
            case 'graphic':
                echo "<p><b>Type Of Designs</b></p>";
                echo "<p><input type='text' name='tod' class='pw'></p>";
                echo "<p><b>Worked On Revisions</b></p>";
                echo "<p><input type='text' name='wor' class='pw'></p>";
                break;
            default:
                echo " ";
    }
    ?>

Greate it worked Thank You

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.