gevensen Posted December 18, 2010 Share Posted December 18, 2010 does jquery have a way to go to a specific table row? I already have the row id and simply want to return to the same position in the table in the event I have to reload the table Quote Link to comment https://forums.phpfreaks.com/topic/222094-going-to-a-specific-table-row/ Share on other sites More sharing options...
bibby Posted December 21, 2010 Share Posted December 21, 2010 Sounds like you might want :eq(), http://api.jquery.com/eq-selector/ It filters the selection to the nth selector. $("#table_id tr:eq("); // the 9th row, in this case. Quote Link to comment https://forums.phpfreaks.com/topic/222094-going-to-a-specific-table-row/#findComment-1149765 Share on other sites More sharing options...
gevensen Posted December 29, 2010 Author Share Posted December 29, 2010 yup that works thanks so much for the pointer its been driving me nuts trying to find in the documentation Quote Link to comment https://forums.phpfreaks.com/topic/222094-going-to-a-specific-table-row/#findComment-1152534 Share on other sites More sharing options...
gevensen Posted December 29, 2010 Author Share Posted December 29, 2010 actually sometimes it works sometimes it doesnt?? Quote Link to comment https://forums.phpfreaks.com/topic/222094-going-to-a-specific-table-row/#findComment-1152569 Share on other sites More sharing options...
gevensen Posted December 29, 2010 Author Share Posted December 29, 2010 i tried another way, making an individual anchor tag for each row I can select the row id fine but is there a way javascript can do this? <a href="#45">Skip to row 45</a> Quote Link to comment https://forums.phpfreaks.com/topic/222094-going-to-a-specific-table-row/#findComment-1152589 Share on other sites More sharing options...
Philip Posted December 29, 2010 Share Posted December 29, 2010 Can you show more code of what you have currently? :eq should work just fine for you, if don properly. Quote Link to comment https://forums.phpfreaks.com/topic/222094-going-to-a-specific-table-row/#findComment-1152717 Share on other sites More sharing options...
gevensen Posted December 30, 2010 Author Share Posted December 30, 2010 i have tried $("#reconcile_table tr:eq(45)"); and $("#reconcile_table tr:eq("+TableRow+")"); where TableRow is a number taken from the last click on the row. I put it in a hidden field then retrieve it for later use? the funny thing is i can use an anchor href and it works I just want to do it as a result of the routine the enitre jquery script is below <script>function select_statement(id){ var Mydata = ''; var lastRow=document.getElementById('lastrow').value; //alert(TableRow); var db ="<?php echo $dbname; ?>"; var user ="<?php echo $_SESSION['username']; ?>"; Mydata=Mydata+"id="+id; Mydata=Mydata+"&account="+document.getElementById('bank_account').value; Mydata=Mydata+"&db="+db; Mydata=Mydata+"&user="+user; Mydata=Mydata+"&lastRow="+lastRow; $("#statement_id").attr("value", id); $("#account_selection_div").hide(); $("#reconcile_div").show(); $('#reconcile_div').html('<img src="../../sc/images/working.gif" height="20" width="20" />'); //alert(Mydata); $.ajax( { url : 'reconcile/show_reconcile_ajax.php', type : 'post', data : Mydata, success : function( resp ) { var $response=$(resp); var reconciled = $response.find('#reconciled_response').html(); var balance = $response.find('#balance_response').html(); var i = $response.find('#i_response').html(); $("#i_value").attr("value", i); // i is the row count in the reconcile table var $response=$(resp); var start = $response.find('#s_response').html(); $("#statement_start").attr("value", start); var $response=$(resp); var end = $response.find('#e_response').html(); $("#statement_end").attr("value", end); $('#reconcile_div').html($('#inner_reconcile_div', resp).html()); if(reconciled>0){ // its reconciled $('#button_table').hideColumns(1); // add expense button $('#button_table').hideColumns(2); // research $('#button_table').hideColumns(3); // reconcile button $('#button_table').showColumns(4); // reverse button $('#reconcile_table').hideColumns(2); // delete in reconcile table $('#reconcile_table').hideColumns(9); // edit in reconcile table $('#reconcile_table').hideColumns(11); // reconcile in reconcile table //alert("reconciled"); } if(reconciled<1){ // its not reconciled $('#button_table').showColumns(1); // add expense button $('#button_table').showColumns(2); // research $('#button_table').hideColumns(3); // default if(balance<.01){ $('#button_table').showColumns(3); } // reconcile $('#button_table').hideColumns(4); // reverse $('#reconcile_table').showColumns(2); // delete in reconcile table $('#reconcile_table').showColumns(9); // edit in reconcile table $('#reconcile_table').showColumns(11); // reconcile in reconcile table } } }); $("#reconcile_table tr:eq(45)"); } </script> Quote Link to comment https://forums.phpfreaks.com/topic/222094-going-to-a-specific-table-row/#findComment-1152960 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.