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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get Hidden Text values from returning page

Status
Not open for further replies.

DougP

MIS
Dec 13, 1999
5,985
US
I have a web page that calls UPS WEB site to return the tracking information. On that page is the Reference 1 “PO-2101” which is our PO and the actual UPS tracking number “1Z blah blah blah”

The UPS tracking number is in a hidden text box on that page.

<INPUT TYPE=&quot;HIDDEN&quot; NAME=&quot;line1&quot; VALUE=&quot;1Z3670451550845123,313092b7c3014d7b00decd94f5622e1509202020,,2020202020202020202020202020202020202020,I,,20011020,065100,ANAHEIM,CA,US,,,,,,20011019,YORBA LINDA,CA,US,NEXT DAY AIR EARLY AM,,,1,20011022,,,,mpts,AR,,,,,,,,,,,2020202020202020202020202020202020202020202020202020202020202020202020,2020202020202020202020202020202020202020,,,,,,,,&quot;>

it’s the first 18 characters in text box &quot;line1&quot;

How can I get that value ???
By using a form.request????

Can someone assist in this??

DougP, MCP

Visit my WEB site to see how Bar-codes can help you be more productive
 
dim trackingNo
trackingNo = left(request.form(&quot;line1&quot;),18)
response.write(trackingNo)

or replace .form with .querystring if the request method is 'get' rather than 'post'
penny.gif
penny.gif
 
Hi link9

I'm not sure where to put your code???
In my calling page

the above HTML is what is returned from UPS so I can't control its content.

here is my page that calls it
---------------------------------------
<html>

<head>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=windows-1252&quot;>
<meta name=&quot;GENERATOR&quot; content=&quot;Microsoft FrontPage 4.0&quot;>
<meta name=&quot;ProgId&quot; content=&quot;FrontPage.Editor.Document&quot;>
<title>Boeing UPS TRACKER by BarcodeONE Corporation&nbsp; Enter your PO number
to the Vendor</title>
</head>

<body>
<FORM method=&quot;post&quot; action=&quot; align=&quot;center&quot;>
Boeing <b> UPS</b> TRACKER by BarcodeONE Corporation<br> &nbsp;Enter your PO number to
the Vendor<br>
<INPUT type=&quot;text&quot; size=17 maxlength=&quot;35&quot; name=&quot;InquiryNumber&quot; value=&quot;PO-&quot;>
<INPUT type=&quot;hidden&quot; name=&quot;SenderShipperNumber&quot; value=&quot;367-045&quot;>
<INPUT type=&quot;hidden&quot; name=&quot;AcceptUPSLicenseAgreement&quot; value=&quot;yes&quot;>
key in &quot;2101&quot; for a test&nbsp; </p>

<p align=&quot;center&quot;>
Note it should be like so PO-2101<INPUT type=&quot;hidden&quot; name=&quot;TypeOfInquiryNumber&quot; value=&quot;R&quot;> </p>

<p align=&quot;center&quot;>
<a href=&quot;howtotrack_upspackages.htm&quot; style=&quot;color: #0000FF&quot;><b>Help</b>&nbsp;</a>&nbsp;&nbsp;&nbsp;&nbsp;
<INPUT type=&quot;hidden&quot; name=&quot;nonUPS_body&quot; value=&quot;BGCOLOR=&quot;#EEEEEE &quot;&quot;>
<INPUT type=&quot;hidden&quot; name=&quot;nonUPS_title&quot; value=&quot;Boeing UPS Tracker by BarcodeONE Corporation&quot;>
<INPUT type=&quot;hidden&quot; name=&quot;nonUPS_header&quot; value=&quot;&lt;CENTER&gt;Boeing UPS Tracker by BarcodeONE Corporation &lt;/CENTER&gt; &lt;HR&gt;&quot;>
<INPUT type=&quot;hidden&quot; name=&quot;nonUPS_footer&quot; value=&quot;&lt;HR&gt; &lt;CENTER&gt;Copyright &copy 2001 BarcodeONE Corporation &lt;/CENTER&gt;&quot;>
<INPUT type=&quot;submit&quot; value=&quot;Track this package&quot;>
<INPUT type=&quot;reset&quot; value=&quot;Clear this package&quot;>
</p>
</FORM>
</body>

</html>
--------------------------------------------------

TIA DougP, MCP

Visit my WEB site to see how Bar-codes can help you be more productive
 
Ahhhhh... I wondered about that myself.

Since you can't control the content of that page, then my best suggestion would be to open a popup window on the page that calls that page right before you submit the form... and then extract the value through that popup window to display to your users...

Would this be a viable option?

If you did do that, then your popup window would have window.opener access to the values on that page.

If you can't do that, then another possible option would be to open the page in a frameset, where you would have control over say, a top frame, or something like that, and then you could access the value through (javascript again), parent.top.frames[index] syntax.

If you need some syntax, let me know, and we could work something out.

The only problem I could see with both of these methods would be determining when the page was loaded so that your page knew when to go grab them, but there has to be some workaround where you could set a function using setTimeout() and then if there's an error (i.e. the page isn't loaded), then wait another two seconds or something like that.

hope that helps! :)
Paul Prewett
penny.gif
penny.gif
 
Sorry it took me so long to get back to you on this one. I guess you can hold this month's check. ;-)

Anyway, you could do it like this:

For your link that was on the page, make it point to a javascript function, passing the url in as a parameter like this:

<a href=&quot;javascript:getInfo(theURL)&quot;;>trackingNoHere</a>

So then you would have a javascript function on that page that would look like:

function getInfo(url){
var popUpURL = 'popup.htm';
var x = window.open(popUpURL,'infoWin','width=500,height=300');
x.moveTo(100,100);
location=url;
}

So that the window would pop open (you'll have to make the popup.htm, which I'll demo in a sec) and then your main window would wisk away to the ups site.

Then, in your popup window, you could do this:

<html>
<head>
<script language=javascript>
function showTracking(){
var trackingNo;
setTimeout(getTracking(trackingNo);,3000);
theSpan.innerHTML.value = trackingNo;
}
function getTracking(trackingNo){
trackingNo = window.opener.forms[0].line1.value;
trackingNo = trackingNo.slice(0,18);
}
</script>
<title>Tracking info</title>
</head>
<body onLoad=&quot;showTracking();&quot;>
<span id=theSpan name=theSpan>Retrieving info...</span>
</body>

So that the page loads up, calls the first function... that function waits three seconds, and then grabs the information, replaing the &quot;Retrieving info...&quot; message with the tracking number.

I'm sorry it's not a vbscript solution, but my client side vbscript is horrible, so maybe someone over in that forum could translate this for you.

The only other thing I could think of is if the page isn't finished loading, it could throw an error because it can't find the element in the opener. I'm not sure what the syntax would be to wait for the page to be loaded, but surely, there must be some.

At any rate, I hope that helps you out.

:)
Paul Prewett
penny.gif
penny.gif
 
Ok
Its close
It pulls up the UPS page and the popup window shows, but there is no data just &quot;Retrieving info...&quot;

It think its happening too fast, like you said.

Is the UPS page suppose to show in its own pop up window too.

DougP, MCP

Visit my WEB site to see how Bar-codes can help you be more productive
 
theSpan.innerHTML.value = trackingNo;

should be:

theSpan.innerHTML = trackingNo;

And if it still doesn't work, then try upping your timeout value by modifying this line:

setTimeout(getTracking(trackingNo);,3000);

to:

setTimeout(getTracking(trackingNo),5000);

Try taking out that extra semicolon, too...

lemme know -
paul
penny.gif
penny.gif
 
Did all that you said
No difference

Did you try this on your Computer????

I have DSL, Windows 2000 Pro, and IE 5.5
PIII 866, 375 meg RAM

DougP, MCP

Visit my WEB site to see how Bar-codes can help you be more productive
 
PS here is my code

In the Calling page
-------------------
<a href=&quot;javascript:getInfo('
<script language=javascript>
function getInfo(url){
var popUpURL = 'popup.asp';
var x = window.open(popUpURL,'infoWin','width=500,height=300');
x.moveTo(100,100);
location=url;
}
</script>
-------------------------------
In the POPUP.htm which I also made a .ASP thinking that's what was wrong.
----------------------
<html>
<head>
<script language=javascript>
function showTracking(){
var trackingNo;
setTimeout(getTracking(trackingNo),5000);
theSpan.innerHTML = trackingNo;
}
function getTracking(trackingNo){
trackingNo = window.opener.forms[0].line1.value;
trackingNo = trackingNo.slice(0,18);
msgbox trackingNo
}
</script>
<title>Tracking info</title>
</head>
<body onLoad=&quot;showTracking();&quot;>
<span id=theSpan name=theSpan>Retrieving info... </span>
</body>
</html>
---------------------------


DougP, MCP

Visit my WEB site to see how Bar-codes can help you be more productive
 
Well crap... I just pasted your url into my function, and although it works fine with a page that I create, it's giving me &quot;Access Denied&quot; javascript error when I try to grab it off of the ups page.

Hmmmm.... So for some reason, that page is kicking us out I guess because the request is coming from a foreign domain. If that is the case, then it's some security measure that they have implemented, and there's not going to be anything you can do about it.

I'm sorry. I should have tested it with that particular page before I gave you the solution.

:-(

I'm going to keep thinking on this, and see if I can come up with a workaround. I'll ask around here at work, too.

Additionally, you might post over in the javascript forum and see if anyone over there might have an idea.

keep me posted, and I'll do the same.

paul
penny.gif
penny.gif
 
can you paste your exact code for the page that works and the one for UPS
I'm not getting an error are you using error trapping??? DougP, MCP

Visit my WEB site to see how Bar-codes can help you be more productive
 
The only thing I did was modify the javascript for the popup page to let the second function do all the work like this:

<script language=javascript>
function showTracking(){
setTimeout('getTracking();',5000);
}
function getTracking(){
var trackingNo;
trackingNo = window.opener.forms[0].line1.value;
trackingNo = trackingNo.slice(0,18);
theSpan.innerHTML = trackingNo;
}
</script>

Admittedly, it's a bit convoluted, and it should probably just be taken care of like this in the body tag:

<body onLoad=&quot;setTimeout('getTracking();',5000);&quot;>

To just completely bypass that first function.

----------------------------

Additionally, I put this function on the page to just test the functionality once I KNEW that the page was loaded just to see if I could grab the value:

function getIt(){
alert(window.opener.forms[0].line1.value);
}

and then put a button on the popup page to call it that looked like this:

<input type=button value=&quot;Get It&quot; onClick=&quot;getIt();&quot;>

So, to recap, my popup.htm looked like this:

---------------------------
Code:
<html>
<head>Getting info...</head>
<script language=javascript>
  function showTracking(){
    //setTimeout('getTracking();',5000);
  }
  function getTracking(){
    var trackingNo;
    trackingNo = window.opener.forms[0].line1.value;
    trackingNo = trackingNo.slice(0,18);
    theSpan.innerHTML = trackingNo;
  }
  function getIt(){
    alert(window.opener.forms[0].line1.value);
  }
</script>
<body onLoad=&quot;showTracking();&quot;>
<span id=theSpan name=theSpan>Getting info...</span>
<br>
<input type=button value=&quot;Get It&quot; onClick=&quot;getIt();&quot;>
</body>

So that for testing purposes, I just commented out the line in the main function so that the only time the page tried to go get the value, I was pushing the button, but no matter which way I tried it, when the ups page was the 'opener', I always got &quot;Access Denied&quot;. But, when I made my own page with a hidden form variable called line1, it got it just fine.

paul
penny.gif
penny.gif
 
Doug,

You might try Using the ADO Stream object, it can open urls. The code would be a little harder to parse out the value you want, but its worth a try. If nothing else you could use the stream to write the page to your own page, then use the exact same methods described in your myriad of other posts.

Dim adoStream
Set adoStream = Server.CreateObject(&quot;ADODB.Stream&quot;)
adoStream.Open url
Response.Write adoStream.Read(adoStream.Size)


PS You must have ADO 2.5 or later for the Stream object to work.

Hope this helps. &quot;A computer scientist is a person who knows when it is time to hit the computer.&quot;

John

johnmc@mvmills.com
 
jmcpher --

I'm interested by your suggestion, and my reading tells me that it should work, but I continue to get errors trying to open a URL with the stream object. I even dumbed the URL way down to this:

<%@language=vbscript%>
<%option explicit%>
<%
dim streamObj
set streamObj = server.createObject(&quot;ADODB.Stream&quot;)
streamObj.open (&quot;Response.Write streamObj.Read(streamObj.Size)
%>

And get this error on the .open line:

Error Type:
ADODB.Stream (0x800A0BB9)
Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
/paul/stream.asp, line 7


Can you shed any light on this for me?

Thanks -
paul
penny.gif
penny.gif
 
here is something from ADO Help
-----------------------------
Step 4: Populate the Details Text Box



[This is preliminary documentation and subject to change.]

To populate the Details text box:

Create a new Sub routine named recFields and insert the following code:

Sub recFields(r As Record, l As ListBox, t As TextBox)
Dim f As Field
Dim s As Stream
Set s = New Stream
Dim str As String

For Each f In r.Fields
l.AddItem f.Name & &quot;: &quot; & f.Value
Next
t.Text = &quot;&quot;
If r!RESOURCE_CONTENTCLASS = &quot;text/plain&quot; Then
s.Open r, adModeRead, adOpenStreamFromRecord
str = s.ReadText(1)
s.Position = 0
If Asc(Mid(str, 1, 1)) = 63 Then '//63 = &quot;?&quot;
s.Charset = &quot;ascii&quot;
s.Type = adTypeText
End If
t.Text = s.ReadText(adReadAll)
End If
If r!RESOURCE_CONTENTCLASS = &quot;application/msword&quot; Then
s.Open r, adModeRead, adOpenStreamFromRecord
s.Type = adTypeBinary
s.Charset = &quot;iso-8859-1&quot;
t.Text = s.Read(adReadAll)
End If
End Sub

This code populates lstDetails with the fields and values of the simple record passed to recFields. If the resource is a text file, a text Stream is opened from the resource record. The code determines if the character set is ASCII and copies the Stream contents into txtDetails.

If the resource record is a Microsoft Word document, a binary Stream is opened from the resource record. The character set is set to iso-8859-1 and the Stream contents are copied into txtDetails.
--------------------------------------------------- DougP, MCP

Visit my WEB site to see how Bar-codes can help you be more productive
 
Sorry, you have to specify a URL like this:
Code:
streamObj.Open &quot;URL=http://google.com&quot;
&quot;Programming is like sex, one mistake and you have to support it forever.&quot;

John

johnmc@mvmills.com
 
Ok I get nothing!!!!
except &quot;Test4&quot;


<%@language=vbscript%>
<%option explicit%>
<%
dim streamObj
set streamObj = server.createObject(&quot;ADODB.Stream&quot;)
streamObj.open (&quot;URL=http://www.google.com&quot;)
Response.Write &quot;Size = &quot; & streamObj.Read(streamObj.Size)
%>
<p>Test4</p>
DougP, MCP

Visit my WEB site to see how Bar-codes can help you be more productive
 
Using this code:

dim streamObj
set streamObj = server.createObject(&quot;ADODB.Stream&quot;)
streamObj.Open &quot;URL=http://consumermetrics.com/default.htm&quot;
Response.Write streamObj.Read(streamObj.Size)


I get &quot;permission denied&quot;.

The problem with trying to get &quot;google.com&quot; I think is that you are asking for a directory, and not a file, so when google's server says &quot;That's a directory, do you want the file?&quot;, our servers see that as an error and return as much, whereas normally, a client would say &quot;Yes, give me the file&quot;.

At any rate, it doesn't matter, because I can't even grab a file off my own server with this method.

How aggravating. It seems like this should be so easy.

>:-< :-(
penny.gif
penny.gif
 
Welllll, it appears I have been saying the wrong thing. In order for any of the ADO components to open a file from a remote server, the server must allow it. Sorry for the glimmer of false hope.

John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top