HTML Tutorial


 Forum HomeForum Home   FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
RegisterRegister - Not registered yet? Got something to say? Join HTML Code Tutorial!
getting information without using submit
Post new topic   Reply to topic    HTML Help Forum Index -> ASP
View previous topic :: View next topic  
Author Message
ollyno1uk



Joined: 23 Jul 2006
Posts: 2

PostPosted: Sun Jul 23, 2006 2:54 am     getting information without using submit Reply with quote

I am trying to use this code to show stock levels in my shop. it checks another website for stock levels when the submit button is pressed. is there a way that i can bypass the submit button and just have the stock level showing when the page loads? here is an example of the code i'm using at the moment

Code:
<form method="post" action="https://www.webpage.com/gateway/get_prod_info.asp">
<input type="hidden" name="sku" value="GLAC51">
<input type="hidden" name="return_string" value="[stock_level] on hand, costing [rrp]">
<input type="hidden" name="reseller_id" value="useratcompany.com">
<input type="hidden" name="reseller_pass" value="pass">
<input type="submit" name="submit" value="submit">
</form>


Thanks for your help
Corey Bryant
Site Admin


Joined: 15 May 2004
Posts: 8255
Location: Castle Rock CO USA

PostPosted: Sun Jul 23, 2006 5:42 am     Reply with quote



If that stock level is in the database couldn't you just pull that number from the database when the page is generated?

_________________
Corey
Loud Info | Loud Worx | Merchant Account Blog
ollyno1uk



Joined: 23 Jul 2006
Posts: 2

PostPosted: Sun Jul 23, 2006 8:50 am     Reply with quote

This is an external database but this is exactly what I would like to do.
degsy



Joined: 23 Feb 2005
Posts: 2440
Location: North East, UK

PostPosted: Mon Jul 24, 2006 10:27 am     Reply with quote

You can use javascript to submit a form onload. This is bad practice as client side javascript can be disabled.

A better option would be to use server side XMLHTTP

Here is an example of posting to a script

Code:

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
If Len(Request.Form) > 0 Then
dim strResponse,destURL,strContent

destURL = "http://domain.com/xmlhttp_post_script.asp"
Response.Write destURL
'Construct the Post Data
strContent = strContent & "name="    & server.URLencode(Request.Form("name"))
strContent = strContent & "&pass="    & server.URLencode(Request.Form("pass"))

'Construct the useragent and send
set http_obj=server.CreateObject("MSXML2.ServerXMLHTTP")   
http_obj.Open "POST", destURL , false
http_obj.setRequestHeader "Content-type", "application/x-www-form-urlencoded"
http_obj.send(strContent)


'Grab the response
strResponse = http_obj.ResponseText

set http_obj=nothing
Response.Write "Form sent"
response.write( strResponse )

End If
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>

<body>
<form name="form1" method="post" action="">
  <p>Name:
    <input name="name" type="text" value="joe">
</p>
  <p>Pass:
    <input name="pass" type="password" value="1234">
</p>
  <p>
    <input type="submit" name="Submit" value="Submit">
  </p>
</form>
</body>
</html>

Display posts from previous:   
Post new topic   Reply to topic    HTML Help Forum Index -> ASP All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
HTML Help Archive
Powered by phpBB © 2001, 2005 phpBB Group
HTML Help topic RSS feed 

 
HOSTING / DESIGN
MAKE MONEY

Home
  |   Tutorials   |   Forum   |   Quick List   |   Link Directory   |   About
Copyright ©1997-2002 Idocs and ©2002-2007 HTML Code Tutorial