Note that there are some explanatory texts on larger screens.

plurals
  1. PODisable a check box after the the checkvalue enter into the database
    primarykey
    data
    text
    <p>book.php</p> <pre><code>&lt;td&gt;&lt;input type="hidden" name="bus_fare" id="bus_fare" value="&lt;?php echo $row['price'];?&gt;"&gt; 1&lt;br&gt; &lt;input type="checkbox" name="seat[]" id="seat_1" value="1" onclick="seat_display(this.value);" /&gt;&lt;/td&gt; &lt;td&gt; &lt;input type="hidden" name="bus_fare" id="bus_fare" value=""&gt; 3&lt;br&gt; &lt;input type="checkbox" name="seat[]" id="seat_3" value="3" onclick="seat_display(this.value);" /&gt;&lt;/td&gt; &lt;td&gt; &lt;input type="hidden" name="bus_fare" id="bus_fare" value=""&gt; 5 &lt;br&gt; &lt;input type="checkbox" name="seat[]" id="seat_5" value="5" onclick="seat_display(this.value);" /&gt;&lt;/td&gt; &lt;input type="text" id="total_seats" name="total_seats" value="" readonly /&gt; </code></pre> <p>javascript</p> <pre><code>&lt;script type="text/javascript"&gt; var tot = 0; function seat_display(val) { seat_no = "seat_"+val; var s_no = document.getElementById(seat_no).value; var fare = parseInt(document.getElementById('bus_fare').value); if(document.getElementById(seat_no).checked) { document.getElementById('total_seats').value += s_no+","; tot=tot+fare; } else { tot=tot-fare; var arr = document.getElementById('total_seats').value; var seatno = arr.split(","); for( var i=0; i&lt;seatno.length; i++ ) { if(seatno[i] == s_no ) seatno.splice(i,1); } document.getElementById('total_seats').value = seatno; if(tot &lt; 0){ tot=0; } } document.getElementById('total_amt').value = tot; } &lt;/script&gt; </code></pre> <p>I want to disable those check boxes which are already checked and the values (checkbox) has already been sent to the database. Each checkbox has it's own unique value, so once an user check 1 or multiple checkbox in the book.php and the checkbox values are sent to the database, when next time another user comes he/she should see the already checked checkboxes are disabled, he/she cant select them. I want to use javascript for this. Any help?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload