以pdf格式打印多个复选框值

时间:2014-09-02 06:58:25

标签: php jquery checkbox tcpdf

我是tcpdf的新手。任何人都可以帮我如何从复选框中读取多个值到tcpdf。 这是我的代码..我无法从复选框中读取多个值。此代码仅从复选框中读取最后选择的值。请帮帮我。

php表单代码

<script type="text/javascript">
    $(function() {
        $("#Submit").click(function(){
            var cper=document.forms["Form"]["cper[]"].value;
    document.getElementById("Form").submit();
        });

    </script>


    <form name="Form" id="Form" method="POST" action="pdf1/pdf1.php">

<label>Please provide upto three committees</label>
        <input type="checkbox" name="cper[]" value="C/C++"><label>C/C++</label><br/>
<input type="checkbox" name="cper[]" value="Java"><label>Java</label><br/>
<input type="checkbox" name="cper[]" value="PHP"><label>PHP</label><br/>
<input type="hidden" name="formType" id="formType" value="MUN" />
            <input type="button" name="Submit" id="Submit" value="Submit" class="formButton" />
        </div>

        </form></div>

        </div>
        </div>

pdf code

require_once('tcpdf_include.php');

// create new PDF document
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);

// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('S');
$pdf->SetTitle('S');
$pdf->SetSubject('S');
$pdf->SetKeywords('S');

// set default header data
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING);

// set header and footer fonts
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));

// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);

// set margins
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);

// set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);

// set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);

// set some language-dependent strings (optional)
if (@file_exists(dirname(__FILE__).'/lang/eng.php')) {
    require_once(dirname(__FILE__).'/lang/eng.php');
    $pdf->setLanguageArray($l);
}


$cper="";
if($_REQUEST["formType"] == "MUN") {
$cper=$_REQUEST["cper"]; 

}
$username = "root";
$password = "";
$hostname = "localhost"; 
$db = "mun";
//connection to the database
$dbhandle = mysql_connect($hostname, $username, $password) or die("Unable to connect to MySQL");
mysql_select_db($db,$dbhandle) or die('cannot select db');
mysql_query("INSERT INTO sjbhsmun1 (Name, age, grade, city, email,mobile, cper, choice1,choice2,choice3) 
                VALUES('$Name', '$age','$grade','$city','$email','$mobile','$cper','$choice1','$choice2','$choice3') ") or die(mysql_error());

----------------
--------

<tr>

                                        <td width="40%" style="border: 1px solid #ccc;">Committee Preferences</td>
                                        <td width="60%" style="border: 1px solid #ccc;">';

    $html .= $cper;

0 个答案:

没有答案