automatic ASP page submission?


T

Terry

I'm trying to automatically submit a form to another ASP page after
some <input> fields values are filled by ASP.

I know I can do it using javascript, but is there a way to
automatically submit the form using VBscript?

Terry

<%
' ... some asp processing
value1 = "something"
value2 = "somethingelse"
%>

<form method="post" action="mynextpage.asp" id="form1" name="form1">
<input TYPE="hidden" name="var1" VALUE=" & <%=value1%> & ">"
<input TYPE="hidden" name="var2" VALUE=" & <%=value2%> & ">"
</form>

<%
' form1.submit() ' this obviously wouldn't do anything
%>


<script language="JavaScript" type="text/javascript">
// this works but is there a way to do it in vbscript.
form1.submit();
</script>
 
Ad

Advertisements

R

Ray at

Why do you need to if you're posting to your own page? Can't you just
execute the code on the serveR? Why create a form that has values
determined by ASP code and then submit it back to the same server?

Ray at work
 
E

Evertjan.

Terry wrote on 16 dec 2003 in microsoft.public.inetserver.asp.general:
I'm trying to automatically submit a form to another ASP page after
some <input> fields values are filled by ASP.

I know I can do it using javascript, but is there a way to
automatically submit the form using VBscript?

Terry

<%
' ... some asp processing
value1 = "something"
value2 = "somethingelse"
%>

<form method="post" action="mynextpage.asp" id="form1" name="form1">
<input TYPE="hidden" name="var1" VALUE=" & <%=value1%> & ">"
<input TYPE="hidden" name="var2" VALUE=" & <%=value2%> & ">"
</form>

<%
' form1.submit() ' this obviously wouldn't do anything
%>


<script language="JavaScript" type="text/javascript">
// this works but is there a way to do it in vbscript.
form1.submit();
</script>

<script type="text/vbscript">
form1.submit()
</script>

Only for IE !!!

Why would you want to do that ?

Are you confusing vbs with (asp)serverside and js with clientside ?

===================

Would you want to do this:

<%
session("value1")=value1
session("value2")=value2
response redirect "myNextpage.asp"
%>

and on "myNextpage.asp"

<%
value1=session("value1")
value2=session("value2")
%>

===============

or

<%
response redirect "myNextpage.asp?"&"value1"&"&"&"value2"
%>

and on "myNextpage.asp"

<%
value1=request.querystring("value1")
value2=request.querystring("value2")
%>
 
T

Terry

Why do you need to if you're posting to your own page? Can't you just
execute the code on the serveR? Why create a form that has values
determined by ASP code and then submit it back to the same server?

Ray at work

Ray, Evertjan,

Thank you for the responses.

I will give a little more info. I was trying to keep it short and
probably confused things a bit by saying 'myNextPage.asp' ... that
page is actually on a 3rd party server.

I am trying to create a standardized ASP page I can call that will
handle 2 (or more) different processing methods for credit cards. One
of our 3rd party vendors accepts a post using a querystring. The
other vendor accepts a form post. So the modified code might look
something like this:

Is there a better to handle this?

Terry

<%
' this ASP page is called by our user's payment form
' .. the page specifies which bankVendor to use.
' ... some initial processing to populate our database
value1 = "something"
value2 = "somethingelse"
' etc.

if BankVendor="A" then
Response.redirect "https://www.bankA.com/payment.asp?" & _
"merchant_id=" & value1 & "&" & "OrdNum=" & value2
elseif BankVendor="B" then
%>
<form method="post" action="https://www.bankB.com/payment.asp"
id="form1" name="form1">
<input TYPE="hidden" name="merchant_id" VALUE=" & <%=value1%> & ">"
<input TYPE="hidden" name="OrdNum" VALUE=" & <%=value2%> & ">"
</form>

<%
' if BankVendor = "B", then I want to submit the form

<script language="JavaScript" type="text/javascript">
// this works but is there a way to do it in vbscript.
form1.submit();
</script>
end if

%>
 
C

Chris Hohmann

Terry said:
Ray, Evertjan,

Thank you for the responses.

I will give a little more info. I was trying to keep it short and
probably confused things a bit by saying 'myNextPage.asp' ... that
page is actually on a 3rd party server.

I am trying to create a standardized ASP page I can call that will
handle 2 (or more) different processing methods for credit cards. One
of our 3rd party vendors accepts a post using a querystring. The
other vendor accepts a form post. So the modified code might look
something like this:

Is there a better to handle this?

Terry

<%
' this ASP page is called by our user's payment form
' .. the page specifies which bankVendor to use.
' ... some initial processing to populate our database
value1 = "something"
value2 = "somethingelse"
' etc.

if BankVendor="A" then
Response.redirect "https://www.bankA.com/payment.asp?" & _
"merchant_id=" & value1 & "&" & "OrdNum=" & value2
elseif BankVendor="B" then
%>
<form method="post" action="https://www.bankB.com/payment.asp"
id="form1" name="form1">
<input TYPE="hidden" name="merchant_id" VALUE=" & <%=value1%> & ">"
<input TYPE="hidden" name="OrdNum" VALUE=" & <%=value2%> & ">"
</form>

<%
' if BankVendor = "B", then I want to submit the form

<script language="JavaScript" type="text/javascript">
// this works but is there a way to do it in vbscript.
form1.submit();
</script>
end if

%>

The following article has a section devoted to posting to an external
resource using MSXML.
http://aspfaq.com/2173

HTH
-Chris Hohmann
 
R

Ray at

Use the link that Chris posted. Are you trying to jerry-rig thins though?
One of your vendors instructs you to grab data from their website and put it
in your own? You'd think they'd offer something to do this for you.

Ray at work
 
Ad

Advertisements

T

Terry

Thanks for the great link. That does it.

But just to clarify... I think you might still be confused on my
setup. The initial user form is on our site, which then calls the ASP
page I am referring to (again on our site), and that decides to which
of the other two external sites it is posted to, depending on the bank
type.

thanks again ... Terry
 
T

Terry

Thought I had it, but on further review, it is still not working
right.

When I use 'MSXML2.ServerXMLHTTP' to post the page, the resulting URL
that appears ends up being on my computer, rather than the remote
server. So then the resulting buttons on THAT page fail, since they
are referencing relatively ( I suppose).

Am I missing something? Or could it mean there is an installation
problem of MSXML2 on my ISP's server. Any other suggestions?

Terry


Here are the two sample pages:

The html form I would like to simulate (this page will work if you
paste it)
test.html:

<HTML>
<HEAD>
<FORM METHOD="POST"
ACTION="https://esqa.moneris.com/hosted/index.php">
<INPUT TYPE="HIDDEN" NAME="store_id" VALUE="store1">
<INPUT TYPE="HIDDEN" NAME="charge_total" VALUE="1.01">
<INPUT TYPE="HIDDEN" NAME="return_URL"
VALUE="http://www.yahoo.com">
<INPUT TYPE="HIDDEN" NAME="receipt_URL"
VALUE="http://www.yahoo.com">
<INPUT TYPE="HIDDEN" NAME="hide_item" VALUE="1">
<INPUT TYPE="HIDDEN" NAME="hide_address" VALUE="1">
<INPUT TYPE="SUBMIT" NAME="SUBMIT" VALUE="Click to proceed to
Secure Page">
</FORM>
</HEAD>
</HTML>



THE ASP page that should(?) submit the info automatically for me:
but, when I run this page, instead of
'https://esqa.moneris.com/hosted/index.php' appearing in my Browser
address bar, it shows: http://mycomputer/mypath/test2.asp
It might be useful if someone could run this on their server (with
good MSXML2 install) to let me know if they get the same as the HTML
form above, or the same as I do.
========================
test2.asp:

<%@ Language=VBScript %>
<HTML>
<HEAD>

<%
dim xmlhttp
url = "https://esqa.moneris.com/hosted/index.php"
set xmlhttp = server.CreateObject("MSXML2.ServerXMLHTTP")
xmlhttp.open "POST", url, false
xmlhttp.setRequestHeader "Content-Type",
"application/x-www-form-urlencoded"

formdata="store_id=store1&" & _
"charge_total=1.01&" & _
"return_URL= www.yahoo.com&" & _
"receipt_URL=www.yahoo.com&" & _
"hide_items=1&" & _
"hide_address=1"

xmlhttp.send formdata
Response.write xmlhttp.responseText
set xmlhttp = nothing
%>
</HEAD>
</HTML>
 
E

Evertjan.

Terry wrote on 16 dec 2003 in microsoft.public.inetserver.asp.general:
Here are the two sample pages:

The html form I would like to simulate (this page will work if you
paste it)
test.html:

<HTML>
<HEAD>
<FORM METHOD="POST"
ACTION="https://esqa.moneris.com/hosted/index.php">
<INPUT TYPE="HIDDEN" NAME="store_id" VALUE="store1">
<INPUT TYPE="HIDDEN" NAME="charge_total" VALUE="1.01">
<INPUT TYPE="HIDDEN" NAME="return_URL"
VALUE="http://www.yahoo.com">
<INPUT TYPE="HIDDEN" NAME="receipt_URL"
VALUE="http://www.yahoo.com">
<INPUT TYPE="HIDDEN" NAME="hide_item" VALUE="1">
<INPUT TYPE="HIDDEN" NAME="hide_address" VALUE="1">
<INPUT TYPE="SUBMIT" NAME="SUBMIT" VALUE="Click to proceed to
Secure Page">
</FORM>
</HEAD>
</HTML>

I think you are making to many problems for yourself.
why not simply startout with:

====================================

<HTML>

<% bank=session("bankname") %>

<body
onload="document.getElementById(""myform"").submit()">

<% if bank = "bankA" then %>

<FORM METHOD="POST" id="myform">
ACTION="https://esqa.moneris.com/hosted/index.php">
<INPUT TYPE="HIDDEN" NAME="store_id" VALUE="store1">
<INPUT TYPE="HIDDEN" NAME="charge_total" VALUE="1.01">
<INPUT TYPE="HIDDEN" NAME="hide_item" VALUE="1">
<INPUT TYPE="HIDDEN" NAME="hide_address" VALUE="1">
</FORM>

<% elseif bank = "bankB" then %>

<FORM METHOD="POST" id="myform">
ACTION="https://Bank.b.com/index.php">
<INPUT TYPE="HIDDEN" NAME="store_id" VALUE="store1">
<INPUT TYPE="HIDDEN" NAME="charge_total" VALUE="1.01">
<INPUT TYPE="HIDDEN" NAME="hide_item" VALUE="1">
<INPUT TYPE="HIDDEN" NAME="hide_address" VALUE="1">
</FORM>

<% elseif bank = "bankC" then %>

<FORM METHOD="POST" id="myform">
ACTION="https://bank.C.com/hosted/index.php">
<INPUT TYPE="HIDDEN" NAME="store_id" VALUE="store1">
<INPUT TYPE="HIDDEN" NAME="charge_total" VALUE="1.01">
<INPUT TYPE="HIDDEN" NAME="hide_item" VALUE="1">
<INPUT TYPE="HIDDEN" NAME="hide_address" VALUE="1">
</FORM>

<% ' else - errorcode for other banks here later? %>

<% end if %>

</Body>
</HTML>

=================================

If this works then you can change the codes for the individual banks,
possibly also adding bankspecific serverside code.

You could write the above far mor efficiently,
but the layout of the code would be less clear.
 
T

Tom Kaminski [MVP]

Terry said:
I'm trying to automatically submit a form to another ASP page after
some <input> fields values are filled by ASP.

I know I can do it using javascript, but is there a way to
automatically submit the form using VBscript?

Terry

<%
' ... some asp processing
value1 = "something"
value2 = "somethingelse"
%>

<form method="post" action="mynextpage.asp" id="form1" name="form1">
<input TYPE="hidden" name="var1" VALUE=" & <%=value1%> & ">"
<input TYPE="hidden" name="var2" VALUE=" & <%=value2%> & ">"
</form>

<%
' form1.submit() ' this obviously wouldn't do anything
%>


<script language="JavaScript" type="text/javascript">
// this works but is there a way to do it in vbscript.
form1.submit();
</script>

Yeah ...

<script language="vbcript">
form1.submit
</script>
 
Ad

Advertisements

T

Terry

Hi Evertjan,

Thank you for your interest. I didn't get a chance to get back to
this today. I hope to tomorrow. I will look at your suggestion and
let you know how I make out.

Terry
 
Ad

Advertisements

T

Terry

Hi Evertjan,

Yes, that's what I need. Got it all working.

Thank you for your persistence.

Terry
 

Top