1

Ok, so I have a table with each row having check boxes at the start of each table row. When a user clicks the table rows he/she wants to display and hits the submit button I want those table rows to show up on another page. I am doing this by creating a variable just like this:

$('#submit').click(function(){

  var data; 
  var title = $('#dimTableTitle td').html();
      data = '<table id="dimTable">';
      data += '<tbody>';
      data += '<tr id="dimTableTitle">' + '<td colspan="100">' + title + '</td>' + '</tr>'
      data += '<tr id="dimHeading">';
           $("#dimHeading").find('td').each(function(){
                 data += '<td>' + $(this).html() + '</td>';

            });
     $('#dimTable tr').has(':checkbox:checked').each(function(){
      data += '<tr>'
           $(this).find('td').each(function(){
                data += '<td>' + $(this).html(); + '</td>'

            });
       data += '</tr>'
    });

    data += '</tr>'
    data += '</tbody>';
    data += '</table>';


    });

The variable 'data' displays just fine on the original page but when I try and load it into a new div or other container on a different page I only receive the entire table, not the selected table rows. I want to display that new variable onto a new page that pops up when a user clicks on the submit button. Any help would be appreciated.

1
  • 1
    JS variables are local to every script, and when you move to another page you realoding the script and initialising the variable. If you want to display JS variables in another page try to use localstorage. diveintohtml5.info/storage.html Commented Dec 9, 2014 at 12:32

2 Answers 2

1

You can send data with post method, (async)

jQuery.ajax({
url: "a.php?" + params,
async: false,
cache: false,
dataType: "html",
success: function(html){
  returnHtml = html;
}

});

Note 1: Source code is written just to give you ideas.

Sign up to request clarification or add additional context in comments.

3 Comments

The site does not make use of PHP however, is that an issue?
If you will use php or similar language , you can use this solution. With only html it will be hard.
I am working with a third party api that does not utilize PHP unfortunately. Javascript and HTML are my only options at the moment. I guess I can search for a plugin.
0

Local storage is the way to go. http://www.w3schools.com/html/html5_webstorage.asp

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.