Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7415537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:19:18+00:00 2026-05-29T07:19:18+00:00

I have a web page configured with the search form in one php page

  • 0

I have a web page configured with the search form in one php page and the table with search results in another and I have the following javascript function that renders the table with the search results:

function createRestaurantsTable() {
var table = document.createElement('table');
var str = '<table cellspacing="1" class="tablesorter">'; 
str += '<thead><tr><th>Nome</th><th>Morada</th><th>Distancia</th></tr></thead>';
for ( var i=0; i< restaurantArr.length; i++){
    str += '<tr><td><center class="IDcell">' + restaurantArr[i].name + '</center></td><td><center>' + restaurantArr[i].address + '</center></td><td><center>' + restaurantArr[i].distance.toFixed(2) + ' m</center></td></tr>';
}
str += '</table>';

str += "<div id='pager' class='pager'>";
str += "<form>"
str += "<img src='Tools/jquery.tablesorter/addons/pager/icons/first.png' class='first'/>";
str += "<img src='Tools/jquery.tablesorter/addons/pager/icons/prev.png' class='prev'/>"
str += "<input type='text' class='pagedisplay'/>";
str += "<img src='Tools/jquery.tablesorter/addons/pager/icons/next.png' class='next'/>";
str += "<img src='Tools/jquery.tablesorter/addons/pager/icons/last.png' class='last'/>";
str += "<select class='pagesize'>"
str += "<option selected='selected'  value='5'>5</option>"
str += "<option value='10'>10</option>";
str += "<option  value='15'>15</option>";
str += "<option  value='20'>20</option>";
str += "<option  value='25'>25</option>";
str += "<option  value='30'>30</option>";
str += "<option  value='35'>35</option>";
str += "<option  value='40'>40</option>";
str += "<option  value='45'>45</option>";
str += "<option  value='50'>50</option>";
str += "</select>";
str += "</form>";
str += "</div>"; 

document.getElementById('restaurants_table').innerHTML = str;

$("table").tablesorter({headers: { 0:{ sorter: false }, 1:{ sorter: false }, 2: { sorter: false }}, widthFixed: true ,widgets: ['zebra']}).tablesorterPager({container: $("#pager")});
$('tr').click(function(event) {
    var id = $(this).find(".IDcell").html();
    if(id) {
        window.location = "index.php?action=register_details&details_view_id=" + id + "&operation=v";
    }

}); 

}

I have a lot more JavaScript code but i think this is enough to show my problem.
How do i render the table if the search form is in another php page?

Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T07:19:20+00:00Added an answer on May 29, 2026 at 7:19 am

    Firstly, you might want not to mix three techniques and try to use just one:

    1. Writing HTML as string can be replaced with JQuery. For instance:

      $("<div>").attr("id", "pager").append(...)   
      
    2. Addressing element by Id by native javascript can be replace with JQuery. (The first technique is faster, but this is rather about simplicity and using one technique instead of mixing them. For inst.:

      $("#restaurant_table).html(insertedHtml);
      

      You might event want to generate your pager like this:

      $("<div>").attr("id", "pager").append(...).appendTo("#restaurant_table");
      
    3. I guess you should address the tablesorter at least by its class:

      $("table.tablesorter")
      
    4. If you generate the structures on-the-fly, you might rather use “live” binder instead of the click binder – the click binder will address only those, which are already constructed by the browser:

      $("table.tablesorter tr").live("click", function(event) {...});
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have web page in PHP which displays all records in a table. I
We have a web page that is configured for Integrated Windows Authentication under ISS.
I have a web page that includes a bunch of images. Sometimes the image
I have a web page with DIV s with a mouseover handler that is
I have a web page x.php (in a password protected area of my web
I have a web page that displays a long line graph inside a div
I have a web page that is being displaying in a winform app using
I have a web page with 3 forms on it. Not nested, just one
I have a web page that shows different messages according to different conditions. I
I have a Error404Servlet which is configured as error-page for 404 in web.xml: <servlet>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.