I like to filter data sets, but I have so many different filters, that I can't load them all at once in the subformular I am using to select them. So I thought I load one by one using Ajax, my PHP-Script sucessfully produce the first part of the formular. It looks like this:
<form action="select_filter.php" method="POST">
<div name="formin" id="formin">
<table border="1">
<tbody>
<tr>
<td rowspan="11"><button onclick="javascript: plusMinTen(0);" type="button"><<<</button></td>
<th>Filter</th>
<td rowspan="11"><button onclick="javascript: plusMinTen(10);" type="button">>>></button></td>
</tr>
<tr>
<td><input type="checkbox" onclick="javascript: this.checked ? takeOut(this.value) : takeIn(this.value) ;" id="filter" value="1" name="filter">Filterwert1</td>
</tr>
...
</tbody>
</table>
</div>
<input type="submit" value="Filter X">
The navigation however don't work. I don't see what im doing wrong, list.php does it jobs when run normaly:
<script>
$(function() {
function plusMinTen(from){
$.get(
"list.php"
{
from: from,
},
function(list){
$('#formin').html(list);
}
);
}
function takeIn(into){
alert("in"+into);
}
function takeOut(out){
alert("out"+out);
}
});
</script>
The functions takeIn and takeOut should add or remove the values temporary to SESSSION array and I have good idea how to do it, but I need to fix this AJAX-Problem first. Another thing I used alert to test if my JS works and it does, but I noticed something strange:
<td><input type="checkbox" onclick="javascript: this.checked ? alert('in'+this.value) : alert('out'+this.value) ;" id="filter" value="14" name="filter">value14</td>
The Value should be taken in when I check the box and out when I uncheck it but in this way it seems visa versa. Because I suspeceted something along this lines:
if(this.checked){
takeOut(this.value);
}else{
takeIn(this.value);
}
but obviously it works the other way round can someone explain?