garethtnash
asked on
Is there a VBScript way of doing this?
Below is some HTML and Javascript that sends a form with some hard coded values (name="username" id="mod_login_username" value="candidate")
Ideally I would like to be able to run this using VBScript instead, and my parameters are variables stored in a database.
I'm comfortable writing a stored procedure that fetches the username and password from the database. I'm comfortable writing an IF statement that processes the next section of code OR redirects the user....
What I would like to do though, is not use HTML or Javascript, so the "next section of code" ideally would be a VBScript function that replaces the Form Post being called, and allows for the values to be called from the database....
So it would look like -
Stored Procedure
Recordset creation
IF Recordset not Null then
Replacement VBScript (Fot HTML / Javascript)
Else Redirect
End If
Is this possible?
Please advise ---- Many thanks :)
Ideally I would like to be able to run this using VBScript instead, and my parameters are variables stored in a database.
I'm comfortable writing a stored procedure that fetches the username and password from the database. I'm comfortable writing an IF statement that processes the next section of code OR redirects the user....
What I would like to do though, is not use HTML or Javascript, so the "next section of code" ideally would be a VBScript function that replaces the Form Post being called, and allows for the values to be called from the database....
So it would look like -
Stored Procedure
Recordset creation
IF Recordset not Null then
Replacement VBScript (Fot HTML / Javascript)
Else Redirect
End If
Is this possible?
Please advise ---- Many thanks :)
<form method="post" action="http://www.site.co.uk/index.php" name="myForm" id="myForm">
<input type="hidden" name="username" id="mod_login_username" value="candidate" />
<input type="hidden" id="mod_login_password" name="passwd" value="candidate" />
</form>
<!-- now send the form! -->
<script type='text/javascript'>document.myForm.submit();</script>
I think I understand what you're asking - and if I do, yes it's possible - you just need to embed your VBScript in your HTML.
<html>
<head>
</head>
<body>
<%
' ASP code to execute SQL query / stored procedure
IF Recordset not Null then
' I forget the syntax for getting data from your recordset,
' but it's not difficult
theUserName = Recordset("username")
theIDdata = Recordset("id")
theCandidateData = Recordset("candidate")
%>
<form method="post" action="http://www.site.co.uk/index.php" name="myForm" id="myForm">
<input type="hidden" name="<% Response.Write theUserName %>" id="<% Response.Write theIDdata %>" value="<% Response.Write theCandidateData %>" />
<input type="hidden" id="mod_login_password" name="passwd" value="candidate" />
</form>
<%
else
Response.Write myRedirectURL
end if
%>
</body>
</html>
ASKER
Thanks, but.... I was actually hoping to organise the form post server side, not client side.... so the page that processes the vbscript is never seen...
Any suggestions? Thank you :)
Any suggestions? Thank you :)
Not sure what you mean - the ASP is processed server side - only HTML is sent to the client.
If it makes it clearer, this is functionally the same:
IF Recordset not Null then
' I forget the syntax for getting data from your recordset,
' but it's not difficult
theUserName = Recordset("username")
theIDdata = Recordset("id")
theCandidateData = Recordset("candidate")
Response.Write "<form method='post' action='http://www.site.co.uk/index.php' name='myForm' id='myForm'>
<input type='hidden' name='" & theUserName &"' id='" & theIDdata "' value='" & theCandidateData "' />
<input type='hidden' id='mod_login_password' name='passwd' value='candidate' />
</form>"
else
Response.Write myRedirectURL
end if
ASKER
Does that process, submit the form? thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
:)
Are you trying to run the checking in a web page or in a SP ?