Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Programatically retrieve text from an IE page

Status
Not open for further replies.

HarryPeltz

Programmer
May 9, 2003
4
US
Hello.. I've posted this question in the Attachmate Extra! forum.. although it really applies to IE.

Is there a way programmatically to send a string into a textbox on an IE page, submit it, then retrieve a string from the resulting page?


I appreciate your help.

thanks,
Harry
 
I assume you mean a web page on another server?

If so then no - however, if you know where the form is being sent to, and its methos (view source for these), then you can replicate the form and send it to the same place.
 
Hello HarryPeltz,

If you have good control over the html-asp page's design, you can do quite a lot from script controlling the IE page. It is sufficient to script through the child objects of it.

Let me illustrate this by simple example. You make a script hosted by wsh, it will control the html/asp page.
Code:
<html>
<head><title>html page : abc.htm</title>
<script language="vbscript">
<!--
function validate()
	if signin.txtname.value = "" then
		msgbox "You've not entered your name."
		validate=false
		document.signin.txtname.focus
		exit function
	end if
	validate=true
	document.signin.submit
end function
-->
</script>
</head>
<body onLoad="document.signin.txtname.focus">
<form name=signin method=post action="xyz.asp">
<input type=text id=txtid name=txtname size=56> <br>
<input type=button id=submitid  name=submitbtn value=Submit onclick="validate()">
</form>
</body>
</html>
Now, the .vbs file is something like this.
Code:
dim oIE
set oIE=createobject("InternetExplorer.Application")

oIE.navigate "abc.htm"   '<<<url
oIE.visible=true
if oIE.busy then wscript.sleep 20 : end if
'wscript.echo "loaded"
set oDoc=oIE.document
oDoc.getElementById("txtid").value="tsuji"
'wscript.echo "Now you see what you have typed into the text input."
msgbox "Now you see what you have typed into the text input.", vbOKOnly, "Windows Script Host"
oDoc.getElementById("txtid").value=oDoc.getElementById("txtid").value & "  " & "- Now I don't want to sign in."
msgbox "Now you see the effect.", vbOKOnly, "Windows Script Host"
iRet=msgbox("Are you ready to submit?", vbYesNo, "Windows Script Host")
If iRet=vbYes Then
	oDoc.getElementById("submitid").click
Else
	'do nothing
End If
msgbox "Do you see the effect?", vbOKOnly, "Windows Script Host"

'oIE.quit
set oIE=nothing
regards - tsuji
 
ace post tsuji,
querystring might be of use to you, Harry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top