8 Replies - 206 Views - Last Post: 07 June 2019 - 08:33 AM

#1 sw1085   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 07-June 19

JQuery Code for use in Scratchpad or Snippets

Posted 07 June 2019 - 07:31 AM

I wondered if someone could help with a script for use in Chrome Snippets or Firefox scratchpad.

I have the below table element displayed in my page:

<table class="table">
                            <tbody>
<tr>
      <th>B Reference</th>
      <th>C Reference</th>
      <th>T Type</th>
      <th>Value Date</th>
      <th>Currency</th>
      <th>Credit Amount</th>
      <th>Debit Amount</th>
      <th>Original Currency</th>
      <th>Post Date</th>

</tr>
</tbody><tbody id="transactionsresult">    
    <tr>
        <td>PT50004572014029972106898</td>
        <td>                <a href="/Client/ClientSearchResultDetailsManagement/19942183" target="_blank">SUPPLIER1</a>


            
        </td>
        <td>DEBIT</td>
        <td>06-Jun-2019</td>
        <td>GBP</td>
        <td></td>
        <td>-2396.62</td>
        <td>EUR 2688.00</td>
        <td>06-Jun-2019</td>
    </tr>
    <tr>
        <td>22430630</td>
        <td>                <a href="/Client/ClientSearchResultDetailsManagement/19949397" target="_blank">SUPPLIER2</a>


            
        </td>
        <td>DEBIT</td>
        <td>06-Jun-2019</td>
        <td>GBP</td>
        <td></td>
        <td>-92.00</td>
        <td> </td>
        <td>06-Jun-2019</td>
    </tr>
    <tr>
        <td>22430630</td>
        <td>                <a href="/Client/ClientSearchResultDetailsManagement/19950622" target="_blank">SUPPLIER3</a>


            
        </td>
        <td>DEBIT</td>
        <td>06-Jun-2019</td>
        <td>GBP</td>
        <td></td>
        <td>-92.00</td>
        <td> </td>
        <td>06-Jun-2019</td>
    </tr>
    
</tbody>
                            
</table>




For every row containing

<a href="
I would like the script to open the link in a new page and extract elements from that page and render it as new columns in the first page.....change the table to have more columns.

from the within the hyperlinks in the table when opened - I have the following h2 element....

<h2><span id="spnClientReference">19942183</span> <span id="traveldate">27-Jun-2019</span> <span id="spnDestination">USA</span> <span id="spnClientReference"></span> <span id="spnClientNAme">Paul Beetle</span><span id="spnAssignedUser">sw1085</span></h2> 


I want to take the spnClientReference, traveldate, spndestination, spnclientname, spn assigned user and add them as columns to the table on the main page where the script was initiated from so the table will have these additional columns with data for every row displayed in the table....

Is that very complicated?

Is This A Good Question/Topic? 0
  • +

Replies To: JQuery Code for use in Scratchpad or Snippets

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15356
  • View blog
  • Posts: 61,560
  • Joined: 12-June 08

Re: JQuery Code for use in Scratchpad or Snippets

Posted 07 June 2019 - 07:35 AM

What have you tried, thought about, or considered?

Additionally if this is your website why not alter to the code on the page to display that information, or create a new page to view it?
Was This Post Helpful? 0
  • +
  • -

#3 sw1085   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 07-June 19

Re: JQuery Code for use in Scratchpad or Snippets

Posted 07 June 2019 - 08:00 AM

View Postmodi123_1, on 07 June 2019 - 07:35 AM, said:

What have you tried, thought about, or considered?

Additionally if this is your website why not alter to the code on the page to display that information, or create a new page to view it?


Its not my page and having the page changed is about 5 months to change I am told! ridiculous I know to create a foreach loop using window.open to pull back the h2 header and appending those to the table.

I am not a developer - I'm the end user. Currently I have to do all of these steps manually.....you can imagine how tedious that gets with 100s or so of rows in a table.....

Can you help Modi?
Was This Post Helpful? 0
  • +
  • -

#4 sw1085   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 07-June 19

Re: JQuery Code for use in Scratchpad or Snippets

Posted 07 June 2019 - 08:08 AM

View Postsw1085, on 07 June 2019 - 08:00 AM, said:

View Postmodi123_1, on 07 June 2019 - 07:35 AM, said:

What have you tried, thought about, or considered?

Additionally if this is your website why not alter to the code on the page to display that information, or create a new page to view it?


Its not my page and having the page changed is about 5 months to change I am told! ridiculous I know to create a foreach loop using window.open to pull back the h2 header and appending those to the table.

I am not a developer - I'm the end user. Currently I have to do all of these steps manually.....you can imagine how tedious that gets with 100s or so of rows in a table.....

Can you help Modi?


From my research:

We need to loop through each row in the table
Use the window.open url to open each hyperlink from the relevant row
Read and store the h2 header which has the IDs I mentioned
Then use appendto to add the new columns with the data relevant for each row until end of all <tr> tags?

If anyone knows how to practically put together a script that does this for use in scratchpad, I would be very grateful as I am now pulling my hair out with the copy and paste work involved :-(

There must be at least one genius on here....
Was This Post Helpful? 0
  • +
  • -

#5 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15356
  • View blog
  • Posts: 61,560
  • Joined: 12-June 08

Re: JQuery Code for use in Scratchpad or Snippets

Posted 07 June 2019 - 08:15 AM

Who's page is it?

Reminder - this is a volunteer forum to promote, discuss, and learn programming. If you want to hire someone to do the work for you, I can shift this to 'post a job'.
Was This Post Helpful? 0
  • +
  • -

#6 sw1085   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 07-June 19

Re: JQuery Code for use in Scratchpad or Snippets

Posted 07 June 2019 - 08:24 AM

View Postmodi123_1, on 07 June 2019 - 08:15 AM, said:

Who's page is it?

Reminder - this is a volunteer forum to promote, discuss, and learn programming. If you want to hire someone to do the work for you, I can shift this to 'post a job'.


It's our data on a someone elses web app but why is that relevant? I am only changing the DOM, right? Not their app. I am changing how I view the data......so not source what ownership of the page has to do with anything.

Its not paid. I am asking someone to show me how to loop through a table, open the hyperlink, search for the IDs, return to the original table, append the contents from the URL H2 header as additional columns in the original table.

Isn't that what I am trying to do? Learn from an expert from someone with more experience.
Was This Post Helpful? 0
  • +
  • -

#7 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15356
  • View blog
  • Posts: 61,560
  • Joined: 12-June 08

Re: JQuery Code for use in Scratchpad or Snippets

Posted 07 June 2019 - 08:30 AM

Quote

It's our data on a someone elses web app but why is that relevant?

Relevant because some sites get pissy about plugins scraping data and jacking with their page code in display.

Case in point, had a buddy running help desk with a company get flooded with 'broken page' and 'messed up data' and all that sort of jazz from clients. Turns out there was a plugin/greasemonkey script (made by an outside source) that multiple people were using doing something similar to what you are asking. After a page change the script wasn't working but people opted to flood the company's help desk.

So, ya know, the joys of examining the larger ramifications and all that jazz. ;)
Was This Post Helpful? 0
  • +
  • -

#8 sw1085   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 07-June 19

Re: JQuery Code for use in Scratchpad or Snippets

Posted 07 June 2019 - 08:31 AM

View Postmodi123_1, on 07 June 2019 - 08:30 AM, said:

Quote

It's our data on a someone elses web app but why is that relevant?

Relevant because some sites get pissy about plugins scraping data and jacking with their page code in display.

Case in point, had a buddy running help desk with a company get flooded with 'broken page' and 'messed up data' and all that sort of jazz from clients. Turns out there was a plugin/greasemonkey script (made by an outside source) that multiple people were using doing something similar to what you are asking. After a page change the script wasn't working but people opted to flood the company's help desk.

So, ya know, the joys of examining the larger ramifications and all that jazz. ;)/>


I'm only the one using that data.....the script would be on my browser only.....
Was This Post Helpful? 0
  • +
  • -

#9 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15356
  • View blog
  • Posts: 61,560
  • Joined: 12-June 08

Re: JQuery Code for use in Scratchpad or Snippets

Posted 07 June 2019 - 08:33 AM

I would suggest picking which browser you are going for, and hitting up their 'getting started' documentation.

Chrome Snippets
https://medium.com/@...ts-7648ff63a4c2
https://developers.g...hrome-devtools/

FF scratch pad
https://developer.mo...ools/Scratchpad
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1