Ниже приведен html / javascript код: я хочу очистить идентификатор в теге tr по клику.Как я могу очистить тег onClick и просто получить идентификатор в конце?Код ниже предназначен для динамической защищенной таблицы веб-сайта, в которой все строки имеют гиперссылки и отсортированы по нечетному и четному классу, как вы увидите ниже.Я признателен за любую помощь, спасибо!
<tr class='odd' onmouseover='mov(this)' onMouseOut="mou(this, 'odd')" onClick='location.href="custlist.php?rptname=Report&custm_id=**13857**"'>
<td align='right'> 1. </td>
<td nowrap style='text-align:;'> Company </td>
<td nowrap style='text-align:;'> blah blah </td>
<td nowrap style='text-align:;'> bbb </td>
<td nowrap style='text-align:right;'> 1,084,771.10 </td>
<td nowrap style='text-align:right;'> 1,060,787.10 </td>
<td nowrap style='text-align:right;'> 1,203,000.00 </td>
<td nowrap style='text-align:right;'> 30,233.90 </td>
<td nowrap style='text-align:left;'> </td>
</tr>
<tr class='even' onmouseover='mov(this)' onMouseOut="mou(this, 'even')" onClick='location.href="custlist.php?rptname=report&custm_id=22012"'>
<td align='right'> 2. </td>
<td nowrap style='text-align:;'> T3 bbhj </td>
<td nowrap style='text-align:;'> hhht </td>
<td nowrap style='text-align:right;'> 720,260.00 </td>
<tr>
* После 25 строк в нем указан код переноса:
<tr class='header'>
<th width='20px'> </th>
<th nowrap>
<a href='/fats/custlist.php?srid=4969&sort=1&desc=ASC&perpage=ALL' class='sorter'>
CUSTOMER</a>
</th>
<th nowrap>
<a href='/fats/custlist.php?srid=4969&sort=2&desc=ASC&perpage=ALL' class='sorter'>
CUSTOMER AGENT</a>
</th>
<th nowrap>
<a href='/fats/custlist.php?srid=4969&sort=3&desc=ASC&perpage=ALL' class='sorter'>
ACCT MANAGERS</a>
</th>
<th nowrap>
<a href='/fats/custlist.php?srid=4969&sort=4&desc=ASC&perpage=ALL' class='sorter'>
TOTAL</a>
<img src='images/up_arrow.gif'>
</th>
<th nowrap>
<a href='/fats/custlist.php?srid=4969&sort=5&desc=ASC&perpage=ALL' class='sorter'>
BALANCE</a>
</th>
<th nowrap>
<a href='/fats/custlist.php?srid=4969&sort=6&desc=ASC&perpage=ALL' class='sorter'>
CREDIT LIMIT</a>
</th>
<th nowrap>
<a href='/fats/custlist.php?srid=4969&sort=7&desc=ASC&perpage=ALL' class='sorter'>
CREDIT AVAILABLE</a>
</th>
<th nowrap>
<a href='/fats/custlist.php?srid=4969&sort=8&desc=ASC&perpage=ALL' class='sorter'>
NOTES</a>
</th>
Мой VBA-код на данный момент:
Sub GetCreditLimit()
Dim ieApp As Object
Dim ieDoc As Object
Dim ieTable As Object
Dim clip As DataObject
Dim td As Object
Dim tr As Object
Dim objTbl As Object
Dim htmlTR As MSHTML.IHTMLElementCollection
Dim htmlTD As MSHTML.IHTMLElementCollection
Dim i As Integer
Dim Links As Object
Dim objElement As HTMLObjectElement
Dim n As Integer
Dim elems As Object
Dim e As Object
'create a new instance of ie
Set ieApp = New InternetExplorer
'you don’t need this, but it’s good for debugging
ieApp.Visible = True
'assume we’re not logged in and just go directly to the login page
ieApp.Navigate "https://brokerage.suntecktts.com/agents/login"
Do While ieApp.Busy: DoEvents: Loop
Do Until ieApp.ReadyState = READYSTATE_COMPLETE: DoEvents: Loop
Set ieDoc = ieApp.Document
'fill in the login form – View Source from your browser to get the control names
With ieDoc.forms(0)
.agent_login.Value = "username"
.agent_password.Value = "password"
.submit
End With
Do While ieApp.Busy: DoEvents: Loop
Do Until ieApp.ReadyState = READYSTATE_COMPLETE: DoEvents: Loop
'now that we’re in, go to the page we want
ieApp.Navigate "https://brokerage.suntecktts.com/fats/custlist.php?srid=8897&page=1&perpage=ALL"
Do While ieApp.Busy: DoEvents: Loop
Do Until ieApp.ReadyState = READYSTATE_COMPLETE: DoEvents: Loop
'get the table based on the table's id
Set ieDoc = ieApp.Document
Set ieTable = ieDoc.all.Item("general-report-wrapper")
'copy the tables html to the clipboard and paste to teh sheet
If Not ieTable Is Nothing Then
Set clip = New DataObject
clip.SetText "<html>" & ieTable.outerHTML & "</html>"
clip.PutInClipboard
ActiveSheet.Range("A1").Select
ActiveSheet.PasteSpecial "Unicode Text"
Rows("1:1").Select
End If
With ieApp
Set ieDoc = ieApp.Document
End With
Do While ieApp.Busy Or Not ieApp.ReadyState = READYSTATE_COMPLETE
DoEvents
Loop
Set objTbl = ieDoc.getElementById("report name")
Set htmlTR = objTbl.getElementsByTagName("tr")
Set htmlTD = htmlTR.getElementsByTagName("td")
Set td = ieDoc.getElementByTagName("td")
For Each tr In htmlTD
ActiveSheet.Range("J2" & Rows.count).Value = tr.onclick
i = i + 1
Next tr
ieApp.Quit
Set ieApp = Nothing
'close 'er up
End Sub