I have created a pagination system, that shows 15 colums from a database. now I want to add a drop down menu with other values, so I can change the pagination variable to 50 or 100.
I have done a javascript, but it wont work as I want to ;) It only read the last value I give the script, And nothing happends when I change the dropdown.
Some of the script
$per_page = 15; // Shows how many colums it shows per page
My javascript
<script type="text/javascript">
function addit(){
if(document.getElementById("add").value=="<?php $per_page = 15; ?>")
{
document.getElementById("amount").value="10"
}
if(document.getElementById("add")."<?php $per_page = 25; ?>")
{
document.getElementById("amount").value="25"
}
if(document.getElementById("add").value=="<?php $per_page = 50; ?>")
{
document.getElementById("amount").value="50"
}
}
</script>
And the form
<form action=" " method="get">
<select style="width: 60px; font-size: 17px;" name="add" id="add" onChange="addit()">
<option value="X"> views</option>
<option value="10">10</option>
<option value="25">25</option>
<option value="50">50</option>
</select>
</td>
</tr>
</tbody>
</table>
</form>
Any tips ?
thanks
if(document.getElementById("add")."<?php $per_page = 25; ?>")is not valid codeif(document.getElementById("add").value=="<?php $per_page = 15; ?>")doesn't make a lot of sense to me....getElementByIdinstead of calling it so often, you can even store the.valuepart. Fourthly, all of those conditionals are running even if a previous one has been found to be true, useelse ifor if that's all the function does justreturnafter a find.