pr0c3ss Posted December 5, 2015 Share Posted December 5, 2015 If the logic of finding values between a min max range = var min = parseInt( $('#min').val(), 10 ); var max = parseInt( $('#max').val(), 10 ); var page = parseFloat( data[11] ) || 0; if ($("#in-range").is(':checked')){ if ( ( isNaN( min ) && isNaN( max ) ) || ( isNaN( min ) && page <= max ) || ( min <= page && isNaN( max ) ) || ( min <= page && page <= max ) ) { return true; } ... what's the logic of displaying values that fall outside of given min/max ranges? for ex. Table holds data 1-9. Min range = 3 max range = 7 the return should be 1,2,3,7,8,9 Quote Link to comment https://forums.phpfreaks.com/topic/299649-minmax-logic-problem/ Share on other sites More sharing options...
requinix Posted December 6, 2015 Share Posted December 6, 2015 Your question does not make sense. Where is 1,2,3,7,8,9 coming from? What does this have to do with the code you posted, which clearly only tries to return true? Quote Link to comment https://forums.phpfreaks.com/topic/299649-minmax-logic-problem/#findComment-1527585 Share on other sites More sharing options...
pr0c3ss Posted December 6, 2015 Author Share Posted December 6, 2015 The code example returns values that fall within the if statement (within entered min and max values)...which works fine... I have been trying to amend this, so it return values that fall outside of a given min and max range. So if table holds data 1-9 and some enters min 3 and max 7 as a range - the return should be 1,2,3,7,8,9 Quote Link to comment https://forums.phpfreaks.com/topic/299649-minmax-logic-problem/#findComment-1527595 Share on other sites More sharing options...
requinix Posted December 6, 2015 Share Posted December 6, 2015 If it correctly returns true for values inside the range, and you want it to now return false for values outside the range, I would expect that all you'd have to do is do an else { return false; }. If that's not it then, What table? What data? Where are all those values coming from? How is the function supposed to return both true/false and something like "1,2,3,7,8,9" (which I assume is either a string or an array)? All that your code demonstrates is 1. Get the min and max values from the form. 2. Get data item 11 (whatever that means) as the page number. 3. Return true if the min and max fit those criteria. Quote Link to comment https://forums.phpfreaks.com/topic/299649-minmax-logic-problem/#findComment-1527596 Share on other sites More sharing options...
pr0c3ss Posted December 6, 2015 Author Share Posted December 6, 2015 (edited) var page = a column in a html table perhaps if I link you this examplehttps://datatables.net/examples/plug-ins/range_filtering.html This searches within a range - like above. I need the search to search outside of the range. So if min and max entered values are 3-7...and page column holds 1-10.... 1,2,3,7,8,9 should return Edited December 6, 2015 by pr0c3ss Quote Link to comment https://forums.phpfreaks.com/topic/299649-minmax-logic-problem/#findComment-1527603 Share on other sites More sharing options...
requinix Posted December 7, 2015 Share Posted December 7, 2015 var page = a column in a html tableNo, it's a float value. This searches within a range - like above. I need the search to search outside of the range. So if min and max entered values are 3-7...and page column holds 1-10.... 1,2,3,7,8,9 should returnOkay. Like I said: you have a function that returns true if something is inside the range, so it should be a simple matter to make it return true if something is outside the range. Change your comparisons so that the page value is = max. Quote Link to comment https://forums.phpfreaks.com/topic/299649-minmax-logic-problem/#findComment-1527615 Share on other sites More sharing options...
pr0c3ss Posted December 10, 2015 Author Share Posted December 10, 2015 above values seem to return but below dont Quote Link to comment https://forums.phpfreaks.com/topic/299649-minmax-logic-problem/#findComment-1527750 Share on other sites More sharing options...
requinix Posted December 10, 2015 Share Posted December 10, 2015 I can guess, but I'll ask anyways: What's your code now? Quote Link to comment https://forums.phpfreaks.com/topic/299649-minmax-logic-problem/#findComment-1527751 Share on other sites More sharing options...
pr0c3ss Posted December 10, 2015 Author Share Posted December 10, 2015 if ( ( min <= page && page >= max ) ) { return true; } full function... $.fn.dataTable.ext.search.push( function( settings, data, dataIndex ) { var inR = document.getElementById("in-range"); var outR = document.getElementById("out-range"); var min = parseInt( $('#min').val(), 10 ); var max = parseInt( $('#max').val(), 10 ); var page = parseFloat( data[11] ) || 0; if ($("#in-range").is(':checked')){ console.log('inrange active'); if ( ( isNaN( min ) && isNaN( max ) ) || ( isNaN( min ) && page <= max ) || ( min <= page && isNaN( max ) ) || ( min <= page && page <= max ) ) { return true; } } else{ console.log('outrange active'); if ( ( min <= page && page >= max ) ) { return true; } } //return false; } ); var table = $('#output').DataTable(); $('#min, #max').keyup( function() { table.draw(); }); }); Quote Link to comment https://forums.phpfreaks.com/topic/299649-minmax-logic-problem/#findComment-1527755 Share on other sites More sharing options...
requinix Posted December 11, 2015 Share Posted December 11, 2015 Why did you comment out the return false? Don't you want it to return false for all the other cases that it didn't return true? Quote Link to comment https://forums.phpfreaks.com/topic/299649-minmax-logic-problem/#findComment-1527794 Share on other sites More sharing options...
pr0c3ss Posted December 11, 2015 Author Share Posted December 11, 2015 Was testing the outcome difference. No worry's about this now...works have annoyingly said another dpt has integrated a solution for what they want... thanks for advice oh requinix Quote Link to comment https://forums.phpfreaks.com/topic/299649-minmax-logic-problem/#findComment-1527800 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.