Hi Daniweb,
I have a checkbox that is dynamically generated using php using inputs on previous pages.

<form name=partselect action="JavaScript:checkmate()" method="post">
        $idpart = oci_result($stmtgp, "PART_ID");
        $stmtparts = oci_parse($conn, "select * from PARTS where PARTID='".$idpart."'");
        $execparts = oci_execute($stmtparts);
            echo 'unable to fetch part';


        $tpartcost = oci_result($stmtgp, "PART_COST")+oci_result($stmtparts, "PARTLABOURCOST");
        echo '<tr>
                <td>'.oci_result($stmtparts, "PARTNAME").'</td>';
        echo '  <td>'.$tpartcost.'</td>';
        echo '  <td><input type=checkbox name=parts value='.$idpart.'>';
        echo '</tr>';    
        <td><input type=Submit value="Confirm">   </td>

I want the results of this checkbox to be passed onto the next php file, where the values that were checked shall be entered into the database. However, I first want to check to make sure that the checkbox is not empty. For this to be implemented, I gathered, the checkbox would have to pass through javascript and once it was deemed full enough, it would be forwarded to the php page. So I wrote the javascript code

<script type="text/javascript">
function checkmate(){
    var partsvar = document.partselect.parts;

    var isempty = true;
    var j = 0;
    for(i = 0; i<partsvar.length; i++){
            isempty = false;
    if(isempty == false){
        var test = 
        window.location.href = "savepartchange.php?w1="+partsvar;
    else if(isempty == true){
        alert("you didnt check anything");

However this is where I am at a loss. I dont know how to send and recieve such arrays between javascript and php. Could someone guide me on what to do here?

Re: Pass over checkbox values through JavaScript into PHP 80 80

You don't need javascript to do this. Additionally, the user could disable javascript.

You should be able to validate a check box with php alone.

Codeigniter has a very handy validate check box method.

Be a part of the DaniWeb community

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