How to get all selected values from multiple select option?

后端 未结 1 2039
天命终不由人
天命终不由人 2021-01-07 03:52

I have a contact form with multiple select option. But there is only 1 value appear in the email after the contact form submitted. Would like to look for solution to get thi

相关标签:
1条回答
  • 2021-01-07 04:54

    Use name as like problems[] instead of problems

    //Simple Form and getting the values
    
    <form name="s" method="post" action="" >
     <select multiple="multiple" name='problems[]' id='problems' class="inpBox multiple" size='50' style="height:150px;" >
            <option value="Cannot Copy">Cannot Copy</option>
            <option value="Cannot Print">Cannot Print</option>
            <option value="Cannot Print">Cannot Scan</option>
            <option value="Cannot Fax">Cannot Fax</option>
            <option value="Lines Appear When Printing/Copying">Lines Appear When Printing/Copying</option>
            <option value="Scan to Email Failed">Scan to Email Failed</option>
            <option value="Toner Low/Empty">Toner Low/Empty</option>
            <option value="Others">Others</option>
    </select>
    <input type="submit" name="submit" value="submit" />
    </form>
    
    
    <?php 
    if (isset($_POST['submit'])) {
        $problems =  implode(',', $_POST['problems']);
        echo $problems;
    }
    ?>
    
    0 讨论(0)
提交回复
热议问题