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

Response Redirect b4 Javascript Onload event??

Status
Not open for further replies.

Cheech

Technical User
Nov 6, 2000
2,933
EU
I have a page that autosubmits an email.
However I need to check the email address is there and then redirect the user if it is missing from the database, if the email address is missing then no email is to be sent.

This works fine with the code I have but once the condition is met ie no email address the page does not redirect but appears to loop in the Onload bit of javascript code.


I have posted this in the Ultradev Forum as well, because in case you didnt guess that is how I have made most of it although the Redirect bit is hand coded in.

The whole script is below any help is greatly appreciated.

<%@LANGUAGE=&quot;VBSCRIPT&quot;%>
<%
Dim rsEmail__MMColParam
rsEmail__MMColParam = &quot;1&quot;
if(Request.QueryString(&quot;stage&quot;) <> &quot;&quot;) then rsEmail__MMColParam = Request.QueryString(&quot;stage&quot;)

%> <%
set rsEmail = Server.CreateObject(&quot;ADODB.Recordset&quot;)
rsEmail.ActiveConnection = &quot;dsn=sku_tracking;&quot;
rsEmail.Source = &quot;SELECT * FROM tbl_email WHERE stage = &quot; + Replace(rsEmail__MMColParam, &quot;'&quot;, &quot;''&quot;) + &quot;&quot;
rsEmail.CursorType = 0
rsEmail.CursorLocation = 2
rsEmail.LockType = 3
rsEmail.Open
rsEmail_numRows = 0
'
'Check the Email address is there and redirect if not
'
strEmailAdd = rsEmail.Fields.Item(&quot;email_address&quot;).Value
If strEmailAdd = &quot;&quot; Then
Response.Redirect &quot;admin_sku_master.asp&quot;
End If
'
'Build the mailto string
'
strSKU = (Request.QueryString(&quot;passedSKU&quot;))
strMailto = (&quot;mailto:&quot; + rsEmail.Fields.Item(&quot;email_address&quot;).Value + &quot;?subject=&quot; + strSKU + &quot;&body=&quot; + rsEmail.Fields.Item(&quot;email_text&quot;).Value)
%>
<html>
<head>
<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
function autosubmit() {
document.form1.submit ()
}
onload=autosubmit;
</SCRIPT>
</head>
<body>
<form name=&quot;form1&quot; method=&quot;post&quot; action=&quot;<%=strMailto%>&quot;>
</form>
<p><a href=&quot;admin_sku_master.asp&quot;>Click here</a> to return to the Master page.

</body>
</html>


I dont want to go to Chelsea!!!
 
A javascript function tweak did it in the end as below..

<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
function autosubmit() {
<%
If strEmailAdd <> &quot;&quot; Then
%>

document.form1.submit ()

<%
End If
%>
}
onload=autosubmit;
</SCRIPT>


I dont want to go to Chelsea!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top