Ask Question Forum:
Model Library:2025-02-08:A.I. model is online auto reply
C
O
M
P
U
T
E
R
2
8
Show
#
ASK
RECENT
←
- Underline
- Bold
- Italic
- Indent
- Step
- Bullet
- Quote
- Cut
- Copy
- Paste
- Table
- Spelling
- Find & Replace
- Undo
- Redo
- Link
- Attach
- Clear
- Code
Below area will not be traslated by Google,you can input code or other languages
Hint:If find spelling error, You need to correct it,1 by 1 or ignore it (code area won't be checked).
X-position of the mouse cursor
Y-position of the mouse cursor
Y-position of the mouse cursor
Testcursor
caretPos
Attachment:===
Asked by duncanb7
at 2024-04-14 15:00:40
Point:500 Replies:7 POST_ID:828474USER_ID:11059
Topic:
Hypertext Markup Language (HTML);Visual Basic Programming;JavaScript
I have one site to login with my login and password by my automation login in VBA. For auto input login/passwrod name,
I can handle by .document.all("USERNAME)="myusername",etc, But for submit button, it has issue becuase
it use "a" tag with href by click. Actually it is not difficult at all if just use a seach do loop as follows
it works fine for me,no any issue up to this moment, but the click to javascript file name of "javascript:PCAQT_validate()"
is always changed by the website adm . So it let me always change my code to adopt its change that is not good.
So I try to other method in its html, at the <a> tag below <img> tag's alt="Sumbit" is always NO change. So I just
ask whether I can check getelementsbyTagName("img").item(0).alt="Sumbit" then go back one node backwards
to its parent node of <a> tage and do a .click. Like we go back one backward step in looking directory in PC at D:cd ...dir-name
Please advise whether it is possbile using img tab's alt and do <a> click
Duncan
Use href to locate the sumbit click in VBA
============================
g=0
do until g>100
if .document.getelementsbyTagName("a").item(g).href= "javascript:PCAQT_validate()" then
.document.getelementsbyTagName("a").item(g).click
g=200
Endif
g=g+1
loop
I can handle by .document.all("USERNAME)="myusername",etc, But for submit button, it has issue becuase
it use "a" tag with href by click. Actually it is not difficult at all if just use a seach do loop as follows
it works fine for me,no any issue up to this moment, but the click to javascript file name of "javascript:PCAQT_validate()"
is always changed by the website adm . So it let me always change my code to adopt its change that is not good.
So I try to other method in its html, at the <a> tag below <img> tag's alt="Sumbit" is always NO change. So I just
ask whether I can check getelementsbyTagName("img").item(0).alt="Sumbit" then go back one node backwards
to its parent node of <a> tage and do a .click. Like we go back one backward step in looking directory in PC at D:cd ...dir-name
Please advise whether it is possbile using img tab's alt and do <a> click
Duncan
Use href to locate the sumbit click in VBA
============================
g=0
do until g>100
if .document.getelementsbyTagName("a").item(g).href= "javascript:PCAQT_validate()" then
.document.getelementsbyTagName("a").item(g).click
g=200
Endif
g=g+1
loop
part of HTML code for taget login website============================================<div><a onclick="document.getElementById('submittype').value = 'click';PCT_LogonMode(0)" href="javascript:PCAQT_validate()"><img alt="Submit" src="/1/themes/html/BDE/images/buttons/btn_submit.gif"></a></div> 1:2:3:4:5:6:
Author: duncanb7 replied at 2024-04-15 09:31:40
Using .Attribute with <a> and <img> tag is also working fine
g = 0
Do Until g > 1000
Err.Clear
On Error Resume Next
If myIE.document.getElementsByTagName("a").Item(g).getElementsByTagName("img").Item(0).Attributes("alt").Value = "Submit" Then
'Debug.Print myie.document.getElementsByTagName("a").Item(g).getElementsByTagName("img").Item(0).Attributes("alt").Value & g & g
If Err.Number = 0 Then
myIE.document.getElementsByTagName("a").Item(g).Click
g = 2000
End If
End If
g = g + 1
Loop
g = 0
Do Until g > 1000
Err.Clear
On Error Resume Next
If myIE.document.getElementsByTagName("a").Item(g).getElementsByTagName("img").Item(0).Attributes("alt").Value = "Submit" Then
'Debug.Print myie.document.getElementsByTagName("a").Item(g).getElementsByTagName("img").Item(0).Attributes("alt").Value & g & g
If Err.Number = 0 Then
myIE.document.getElementsByTagName("a").Item(g).Click
g = 2000
End If
End If
g = g + 1
Loop
Author: duncanb7 replied at 2024-04-15 09:16:59
myIE.document.getElementsByTagName("img").Item(g).parentNode.Click
it works back
Thanks for your reply
it works back
Thanks for your reply
Expert: Chaitanya yarlagadda replied at 2024-04-15 08:07:47
try
obj.parentNode.firstChild.Click
<div>
<a onclick="document.getElementById('submittype').value = 'click';PCT_LogonMode(0)" href="javascript:PCAQT_validate()"></a>
<img alt="Submit" src="/1/themes/html/BDE/images/buttons/btn_submit.gif">
</div>
obj.parentNode.firstChild.Click
<div>
<a onclick="document.getElementById('submittype').value = 'click';PCT_LogonMode(0)" href="javascript:PCAQT_validate()"></a>
<img alt="Submit" src="/1/themes/html/BDE/images/buttons/btn_submit.gif">
</div>
Author: duncanb7 replied at 2024-04-15 07:34:35
Finally I ca n get the location of my target img tab from the following code
Now I try the click both method is fail
1-myIE.document.getElementsByTagName("img").Item(g).parentnode.Click
'2-this.parentnode.click, Why ?Please Duncan
Code for getelementbyTagName("img") and its attributes of "alt"
====================================
g = 0
Do Until g > 1000
Err.Clear
On Error Resume Next
If myIE.document.getElementsByTagName("img").Item(g).Attributes("alt").Value = "Submit" Then '
If Err.Number = 0 Then
'myIE.document.getElementsByTagName("img").Item(g).parentnode.Click
' this.parentnode.click
g = 2000
End If
End If
g = g + 1
Loop
Now I try the click both method is fail
1-myIE.document.getElementsByTagName("img").Item(g).parentnode.Click
'2-this.parentnode.click, Why ?Please Duncan
Code for getelementbyTagName("img") and its attributes of "alt"
====================================
g = 0
Do Until g > 1000
Err.Clear
On Error Resume Next
If myIE.document.getElementsByTagName("img").Item(g).Attributes("alt").Value = "Submit" Then '
If Err.Number = 0 Then
'myIE.document.getElementsByTagName("img").Item(g).parentnode.Click
' this.parentnode.click
g = 2000
End If
End If
g = g + 1
Loop
Expert: Chaitanya yarlagadda replied at 2024-04-15 06:45:32
can you elborate your problem??
Author: duncanb7 replied at 2024-04-15 06:39:49
You means.
.document.getlementsByTagName(img").item(0).paremtNode.click., IS it right ?
What is "this", could provide a lot code for this
.document.getlementsByTagName(img").item(0).paremtNode.click., IS it right ?
What is "this", could provide a lot code for this
Accepted Solution
Expert: MlandaT replied at 2024-04-15 03:07:58
500 points GOOD
you would have to use the onclick im the img tag. and just use 'this.parentNode' in that handler to get teh parent A tag.