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

How to control Page Refresh

Status
Not open for further replies.

Ken100

Programmer
Oct 29, 2007
6
US
In my ASP form I am passing some info to a third Party search tool using some javascript and asp.When I refresh the page again this code is executing.
I want this code to execute when the page is first loaded.
It should not execute on refresh.
Here is the code I wrote.

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
<%@ language = VBScript%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>test</title>
<%
Dim strCategory
%>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="VBScript">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content=" <script language="javascript">
<script language="javascript">
function checkRefresh()

{
if (document.Form1.visited.visible="")
{
document.Form1.visited.value ="1";
}
}
</script>
</HEAD>
<body MS_POSITIONING="GridLayout" onload="javascript:checkRefresh();">
&nbsp;
<form id="Form1" method="post">
<input type="hidden" name="visited" id ="visited">
</form>

<% If not (Request.Form("visited")>0) then %>
<% '// if visited.value <>"" then %>
<% if (Request.QueryString) <> "" then %>
<% get_Category()%>
<% if len(Request.QueryString("sid"))>0 then %>
<script language="javascript">
roi_conversion ="<%=Request.QueryString("sid")%>";
roi_category = "<%=strCategory%>";
</script>
<% elseif len(Request.QueryString("sid"))=0 then %>
<script language="javascript">
roi_conversion ="0.00";
roi_category = "<%=strCategory%>";
</script>
<% end if %>
<% end if %>
<% end if%>
</body>
</HTML>
<%
Function get_Category()
Dim nsid
nsid = Request.QueryString("sid")
If nsid = 107 or nsid = 108 or nsid = 138 or nsid = 139 Then
strCategory = "Price Database"
Elseif nsid = 4 Then
strCategory = "Newsletter"
Elseif nsid = 132 Then
strCategory = "Market Alert"
Elseif nsid = 141 or nsid = 143 or nsid = 144 or nsid = 147 or nsid = 145 Then
strCategory = "Market Performance"
Elseif nsid = 1 Then
strCategory = "New User"
Else
strCategory = "Free Market Alert"
End If
End Function
%>

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

In the above code I have created a hidden field(visited) and trying to pass the value to it. But I am getting error
"document.Form1.visited is null or Object not found" error
Some body help me.
 
[1] Doubled up - why?
><script language="javascript">
<script language="javascript">

[2]
>if (document.Form1.visited.visible="")
[2.1] If you want test comparing value
[tt]if (document.Form1.visited.visible=[red]=[/red]"") [red]//still wrong[/red][/tt]
[2.2] So what is .visible? It is not a custom attribute on the face of it. A remotely probable is something along the line of .style.display, but it seems pushing the imagination on my part too far. Besides, it is a hidden field after all.
[3]
><form id="Form1" method="post">
[tt]<form id="Form1" [red]name="Form1"[/red] method="post">[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top