Jump to content

How to insert element in IE Page ?


jmp
 Share

Recommended Posts

Hello, 

When I click on Okra tab 

Figure  1️⃣

589738780_billdetail000.thumb.JPG.e419777c98de40f912861a710bb69267.JPG

Open new page like this :

Figure 2️⃣

1232863232_okraprint.thumb.JPG.6d9a7769aa2895bb70faee3762baf62c.JPG

When i click Potatoes tab it also open new page like this :

Figure 3️⃣

1597345817_potatoesprint.thumb.JPG.5a0ffca715ee053481a00cb9a8767e59.JPG

But i want to print this two document in one page, like this :

1014140534_billprint00.thumb.JPG.9158221e5b30dbdb1dc2fd4a208bb934.JPG

1. First Identify the lower number written Before the item in figure 1 (30, 31)

2. Click on lower number tab and copy the elements of potatoes or any lower number item

3. Return to figure 1 and click on higher number item like Okra (Have 31 number)

4. Past the copied elements before the Okra's elements

5. Set no. in first tab like 1,2,3...

4. Sum the price of all elements and set it to total price 

5. sum the total price and labour charge and set it to total paid amount

I hope you understand my bad english

html code of Figure 1️⃣

1612409748_billdetail.JPG.c1ae7bc3f563b4a4f36e2157919f4e34.JPG

Figure 2️⃣ :

22414390_billprint.JPG.be0428ab728171e0467c948ddc205fca.JPG

Figure 3️⃣ :

1061818792_potatoeshtml.JPG.f2e20d823a66390991383ced4ed32a7e.JPG

Link to comment
Share on other sites

We don't have enough information to give you an exact answer.  #1 is obviously a table, look at _IE_Table* function to reach the right table and read it into an array. As for the rest, try producing some code so we can understand what you are trying to do...

Link to comment
Share on other sites

On 8/5/2019 at 7:51 PM, Nine said:

We don't have enough information to give you an exact answer.  #1 is obviously a table, look at _IE_Table* function to reach the right table and read it into an array. As for the rest, try producing some code so we can understand what you are trying to do...

@Nine, I tried to get table using :

#include <IE.au3>
#include <Array.au3>
$oIE = _IEAttach ("Shop")
$oTable = _IETableGetCollection ($oIE, 0)
$aTableData = _IETableWriteToArray ($oTable)
$iNumTables = @extended
MsgBox(0, "Table Info", "There are " & $iNumTables & " tables on the page")
_ArrayDisplay($aTableData)

But, It did not find any table.

and I don't want to read the whole table, I want to read the all number that is written before the items372022758_reddot.thumb.jpg.e692664b0af5a3b9623276a95b8c3ae1.jpg.

Then identify which is the smaller number of them.

Link to comment
Share on other sites

I know what you want.  The problem is that I don't have enough info to help you (DOM is too partial).  You are telling us that there is no table, but $iNumTables is placed wrong.  It should be after the get collection !  Remove the 0 in the get collection, so you know how many tables you have. Check for @error at each step...

Edited by Nine
Link to comment
Share on other sites

14 hours ago, Nine said:

I know what you want.  The problem is that I don't have enough info to help you (DOM is too partial).  You are telling us that there is no table, but $iNumTables is placed wrong.  It should be after the get collection !  Remove the 0 in the get collection, so you know how many tables you have. Check for @error at each step...

@Nine i am getting two tables using :

#include <IE.au3>
#include <Array.au3>
$oIE = _IEAttach ("Shop")
$oTable = _IETableGetCollection ($oIE, 1)
$iNumTables = @extended
$aTableData = _IETableWriteToArray ($oTable)
MsgBox(0, "Table Info", "There are " & $iNumTables & " tables on the page")
_ArrayDisplay($aTableData)

Now, How can i read the all number that is written before the items then identify which is the smallest number of them ?

Link to comment
Share on other sites

I am get table using :

#include <IE.au3>
#include <Array.au3>
$oIE = _IEAttach ("Shop")
$oTable = _IETableGetCollection ($oIE, 1)
$aTableData = _IETableWriteToArray ($oTable)
Local $aExtract = _ArrayExtract($aTableData, 0, 5, 1, 1)
_ArrayDisplay($aExtract, "Row 1-2 cols 2-3")

How Can i insert it before Okra Row ?

1199017465_okraprint.thumb.JPG.1891e0ff2d3f9d7742aa32813c59137c.JPG

HTML :

 1347484111_billprint.JPG.fba2f86e4666f2e8b5a15afc71e6466d.JPG

I am trying using

Local $oDiv = _IEGetObjById($oIE, "itemDetails")
_IEDocInsertHTML($oDiv, $aExtract, "afterend")

But it was not working

Link to comment
Share on other sites

If you have read the help file, you would have seen that the second parameter of _IEDocInsertHTML is a string not an array.  If you had look at the example, you would have noted, that the string is HTML formatted tags.  Now that you know that, you will have to copy the desired tags (from the DOM you posted) into a string like :

Local $sHTML = _
'<tr>' & @CRLF & _
'  <td>%1%</td>' & @CRLF & _
'  <td>%2%</td>' & @CRLF & _
'  <td style="text-align: left;">%3%</td>' & @CRLF & _
  ....
'</tr>'

Then you will use _IETagGetCollection to locate the tr object of Okra, You will replace %1%, %2%, etc with the right values coming from your array, and use _IEDocInsertHTML to insert the string after the object found.  And please do not ask me to provide you with the code, I will not do it for you. By now you should be able to solve this by yourself. :)

Edited by Nine
Link to comment
Share on other sites

  • Moderators

@jmp Stick to one topic please. Spamming the forum will not get you faster answers.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Instead of using _IETagGetCollection and since you already have the table object, I would suggest you use .firstElementChild and .nextElementSibling properties of the table object to reach the tr object of  Okra.  See this site for a list of available DOM elements.

Link to comment
Share on other sites

21 hours ago, Nine said:

Instead of using _IETagGetCollection and since you already have the table object, I would suggest you use .firstElementChild and .nextElementSibling properties of the table object to reach the tr object of  Okra.  See this site for a list of available DOM elements.

@Nine i can't understand with this site, please give me little example how can i use it? 

Edited by jmp
Link to comment
Share on other sites

On 8/10/2019 at 4:45 PM, Nine said:

If you have read the help file, you would have seen that the second parameter of _IEDocInsertHTML is a string not an array.  If you had look at the example, you would have noted, that the string is HTML formatted tags.  Now that you know that, you will have to copy the desired tags (from the DOM you posted) into a string like :

Local $sHTML = _
'<tr>' & @CRLF & _
'  <td>%1%</td>' & @CRLF & _
'  <td>%2%</td>' & @CRLF & _
'  <td style="text-align: left;">%3%</td>' & @CRLF & _
  ....
'</tr>'

Then you will use _IETagGetCollection to locate the tr object of Okra, You will replace %1%, %2%, etc with the right values coming from your array, and use _IEDocInsertHTML to insert the string after the object found.  And please do not ask me to provide you with the code, I will not do it for you. By now you should be able to solve this by yourself. :)

@Nine I am trying to add element using this code 

#include <IE.au3>
$oIE = _IEAttach ("Shop")
$oTable = _IETableGetCollection($oIE,0)
Local $oTds2 = _IETagNameGetCollection($oIE, "tbody")
$iOutStanding1 = $oTds2(1)
Local $sHTML = _
'<tr>' & @CRLF & _
'  <td>New Item here</td>' & @CRLF & _
'  <td>Some text here</td>' & @CRLF & _
'</tr>'
_IEDocInsertText($iOutStanding1, $sHTML, "afterbegin")

But it was add incorrectly like this

elements.JPG.ad97994905067d57fb1e74c022d020b2.JPG

Link to comment
Share on other sites

13 hours ago, jmp said:

@Nine I am trying to add element using this code 

#include <IE.au3>
$oIE = _IEAttach ("Shop")
$oTable = _IETableGetCollection($oIE,0)
Local $oTds2 = _IETagNameGetCollection($oIE, "tbody")
$iOutStanding1 = $oTds2(1)
Local $sHTML = _
'<tr>' & @CRLF & _
'  <td>New Item here</td>' & @CRLF & _
'  <td>Some text here</td>' & @CRLF & _
'</tr>'
_IEDocInsertText($iOutStanding1, $sHTML, "afterbegin")

But it was add incorrectly like this

elements.JPG.ad97994905067d57fb1e74c022d020b2.JPG

@Nine Please help me

Link to comment
Share on other sites

On 8/12/2019 at 8:37 PM, jmp said:

@Nine I am trying to add element using this code 

#include <IE.au3>
$oIE = _IEAttach ("Shop")
$oTable = _IETableGetCollection($oIE,0)
Local $oTds2 = _IETagNameGetCollection($oIE, "tbody")
$iOutStanding1 = $oTds2(1)
Local $sHTML = _
'<tr>' & @CRLF & _
'  <td>New Item here</td>' & @CRLF & _
'  <td>Some text here</td>' & @CRLF & _
'</tr>'
_IEDocInsertText($iOutStanding1, $sHTML, "afterbegin")

But it was add incorrectly like this

elements.JPG.ad97994905067d57fb1e74c022d020b2.JPG

Hello @Nine

I am adding table using _IEDocInsertHTML.

Now, How can i set number in sequence like 1,2,3.... ?

Link to comment
Share on other sites

It seems like you are trying to manipulate a webshop page.

I have severe doubt if that will work as the backend of the shop will not be able to handle your manipuluation of the HTML so as soon as you refresh your changes are gone.

You should only be able to manipulate the elements like buttons, images with click or set value.

 

 

Link to comment
Share on other sites

On 8/17/2019 at 3:49 AM, junkew said:

It seems like you are trying to manipulate a webshop page.

I have severe doubt if that will work as the backend of the shop will not be able to handle your manipuluation of the HTML so as soon as you refresh your changes are gone.

You should only be able to manipulate the elements like buttons, images with click or set value.

 

 

@junkew I am not trying to manipulate a webshop page,  I just try to save paper.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...