Note that there are some explanatory texts on larger screens.

plurals
  1. PODetermining the proper table on a page using .index
    primarykey
    data
    text
    <p>I am developing a simple jQuery solution for a client that will carry information over from a table on this page: <a href="http://yft.ac/upcoming-workshops/" rel="nofollow">http://yft.ac/upcoming-workshops/</a>, to the "Workshop Interested" field on this page: <a href="http://yft.ac/contact-us/" rel="nofollow">http://yft.ac/contact-us/</a>. I am doing this using the Local Storage API but am running into a problem. </p> <p>You will notice that if you click any of the three buttons under the "YFT Admissions Insights" heading, that all of the information is being carried over to the required input. However, whenever you click a button underneath the "YFT Intensive Application Workshop", only <em>some</em> of the information is being carried over, and whenever you click under the "YFT Head Start", none of the information is being carried over. </p> <p>Here is the code I am working with: </p> <p><strong>Upcoming Workshops Page:</strong></p> <pre><code>jQuery(function ($) { $('body').on('click', 'a.button', function () { // Variables var index = $(this).parents('table').index('table'); var buttonIndex = $("a.button").index(this); buttonIndex+=1; //Add one to our index so we ignore the &lt;tr&gt; values in the &lt;thead&gt; var cur_workshop_name = $(this).parents('.innercontent').find('h3').eq(index).text(); var cur_workshop_date = $(this).parents('.innercontent').find('tr:nth-of-type(' + buttonIndex + ') td:first-child').eq(index).text(); var cur_workshop_location = $(this).parents('.innercontent').find('tr:nth-of-type(' + buttonIndex + ') td:nth-of-type(3)').eq(index).text(); //Set Item in Local Storage localStorage.setItem('workshop', cur_workshop_name + ' | ' + cur_workshop_location + ' | ' + cur_workshop_date); }); }); </code></pre> <p><strong>Contact Us Page:</strong></p> <pre><code>jQuery(function ($) { //Output value in respective field $('#workshop').val( localStorage.getItem('workshop') ); }); </code></pre> <p>I really pieced this together using my intermediate skills in jQuery, but I think that the problem is happening because of either the multiple tables on the page (there are three), or multiple instances of the <code>innercontent</code> class (there are three). </p> <p>I would appreciate any and all help in sorting this little problem out, thanks in advance!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload