I am currently working on my protfolio for school. And i want to be able to filter and display my portfolio items by clicking 1 or more of the subjects, wich are chechboxes.
(for example like they did on this site: http://ift.tt/1N0sSSv )
I want to do this whitout clicking a submit button. But when a chekbox is checked or unchecked it wil "submit".
I had everything working until i wanted to auto-submit by chekking.
My code is like this:
<form id="form" method="post" action="">
<p><input class="chekbox" onchange="$('#form').submit();" type="checkbox" name="vak[]" value="SCO">SCO</p>
<p><input class="chekbox" onchange="$('#form').submit();" type="checkbox" name="vak[]" value="UXU">UXU</p>
<p><input class="chekbox" onchange="$('#form').submit();" type="checkbox" name="vak[]" value="DED">DED</p>
<p><input class="chekbox" onchange="$('#form').submit();" type="checkbox" name="vak[]" value="PTT">PTT</p>
<p><input class="chekbox" onchange="$('#form').submit();" type="checkbox" name="vak[]" value="PPM">PPM</p>
</form>
So i removed the submit button because now it will auto submit. Yet if afther submitting and changing the displayed content the chekbox is unchecked. so if i check another checkbox it will directly submit and change display of newly checked box. So i cant select conect from multiple checkboxes.
Already tried to check box if vak isset. But then he checkes all boxes, because they are all same name. And i cant change name becuase then the wilde loop of displaying items wont work.
Here is the php
code
if(isset($_POST["vak"])){
if(!empty($_POST["vak"])){
foreach ($_POST["vak"] as $vak){
$select = "select * from portfolio where vak like '%$vak%'";
$run = mysqli_query($con, $select);
while ($row = mysqli_fetch_array($run)){
$id = $row['ID'];
$titel = $row['titel'];
$datum = $row['datum'];
$auteur = $row['auteur'];
$image = $row['image'];
$image2 = $row['image2'];
$image3 = $row['image3'];
$image4 = $row['image4'];
$keywords = $row['keywords'];
$inhoud = substr($row['beschrijving'],0,100);
I hope its claer what i want and whats not working and someone here can help me.
Thnx in advanced.
Aucun commentaire:
Enregistrer un commentaire