|
-
Nov 25th, 2006, 01:43 PM
#1
Thread Starter
Member
[RESOLVED] A different problem with Webbrowser control
I'll explain my situation.
I have a webbrowser control in my form using which I fill a form a submit data. The comment submission form is supposed to have 3 text boxes but sometimes there could be 4. So I need to know the exact number before trying to fill the form. Also the issue is there could be more than one form in this page and therefore I can't call it like form(0) or form(1) as the index can vary. But the good thing is the id of the form to be filled is always the same. So I can call it with getelementbyid("postform").
So my question is how can I count the no.of text boxes belonging to the form with id "postform"?
Last edited by Inman; Nov 29th, 2006 at 02:07 PM.
-
Nov 25th, 2006, 09:07 PM
#2
Stuck in the 80s
Re: A different problem with Webbrowser control
I'm not sure how to do it with the webbrowser control, but it do it via javascript, you would do:
Code:
function CountTexts()
{
var iTexts = 0;
for( i = 0; i < document.getElementById( "postform" ).elements.length; i++ )
{
if( document.getElementById( "postform" ).elements[ i ].type == 'text' )
{
iTexts++;
}
}
return( iTexts );
}
Hopefully this helps in some way. If you can loop the elements and count their type in VB, this should get you the number of input type=text.
-
Nov 27th, 2006, 12:13 PM
#3
Thread Starter
Member
Re: A different problem with Webbrowser control
Thanks Hobo. Let me try to convert it to VB.
-
Nov 27th, 2006, 12:43 PM
#4
Re: A different problem with Webbrowser control
I think this should do:
VB Code:
Private Sub Command1_Click()
Dim oElement
Dim n As Long
For Each oElement In WebBrowser1.Document.getElementById("postform").Elements
If oElement.Type = "text" Then
n = n + 1
End If
Next
MsgBox "No. of text fields: " & n
End Sub
Pradeep
-
Nov 29th, 2006, 02:07 PM
#5
Thread Starter
Member
Re: A different problem with Webbrowser control
Thank you Pradeep. It really worked.
Also many thanks to Hobo for giving me something to start with.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|