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

not refreshing!

Status
Not open for further replies.

craigey

Technical User
Apr 18, 2002
510
GB
The page is an online database editor.

The code on my home PC works perfectly, No problems at all. However I have
tried to run the page on the intranet server at work, All seems to be OK.
Except for when you add/update/delete to/from the database. The page
doesn't refresh with the new information on the database. It just stays the
same, unless you refresh the page manually or close the browser and go to
the page again or if you re-order the list. So I know the database is being
updated correctly. If you manually refresh the page after adding a new url,
you actually get 2 of the same url's in the database as you have to resend
the information to the page when you do a refresh.

I have tried playing with the code to try to figure out why this is
happening or any way round it, but I'm getting no-where. Can you please
take a look and see if there is anything you can think of to get around
this?


The code is below:

Code:
<%
Option Explicit

Dim page_name
page_name = &quot;editurls.asp&quot;

'********************************* Defining a couple variables ****************
Dim strConnect
strConnect = &quot;urlcheck&quot;
Dim next_action
If Request.Form(&quot;next_action&quot;) <> &quot;&quot; Then
	next_action = Request.Form(&quot;next_action&quot;)
Else
	next_action = &quot;show list&quot;
End If

'********************************* Show List **********************************
Function show_list
	Dim objCommand
	Dim sqlGetList
	Dim rsGetList
	Dim order_by															' addition to code 1 line

	If Request.Form(&quot;reorder&quot;) <> &quot;&quot; Then									' addition to code 5 lines
		order_by = request.Form(&quot;reorder&quot;)
	Else
		order_by = &quot;websitename&quot;
	End If

	sqlGetList = &quot;SELECT * FROM urllist ORDER BY &quot;&order_by					'line changed for order_by variable

	on Error Resume Next
		Set objCommand = Server.CreateObject(&quot;ADODB.Command&quot;)
		objCommand.ActiveConnection = strConnect
		objCommand.CommandText=sqlGetList
		objCommand.CommandType=adCmdText
		Set rsGetList = objCommand.Execute
		Set objCommand = Nothing

	rsGetList.MoveFirst

	'---- Do the display now
	%>
	<form method=POST action=&quot;<%=page_name%>&quot; name=&quot;frmUrlList&quot;>
	<input type=&quot;hidden&quot; name=&quot;next_action&quot; value=&quot;show list&quot;>
	<input type=&quot;hidden&quot; name=&quot;record_number&quot;>
	<input type=&quot;hidden&quot; name=&quot;reorder&quot; value=&quot;websitename&quot;>			<% 'additional element for reorder %>
	<table class=&quot;urlListTable&quot;>
		<tr>
			<th><a class=&quot;headers&quot;>Options</a>
			</th>
			<th>
			<a href=&quot;#&quot; onClick=&quot;frmUrlList.reorder.value='websitename'; textSubmit('frmUrlList');&quot; class=&quot;headers&quot;>Website</a>
			</th>
			<th><a href=&quot;#&quot; onClick=&quot;frmUrlList.reorder.value='url'; textSubmit('frmUrlList');&quot; class=&quot;headers&quot;>Address</a>
			</th>
			<th>
				 
			</th>
			</tr>
	<%
	Dim rowCounter
	Do While NOT rsGetList.EOF
		%>
		<tr class=&quot;listRow<%=(rowCounter mod 2)%>&quot;>
			
			<td align=&quot;center&quot;>	<% ' code changes follow, use javascript textSubmitCheck for delete to confirm %>
				<input type=&quot;button&quot; value=&quot;Update&quot; onClick=&quot;frmUrlList.record_number.value='<%=rsGetList(&quot;urlPK&quot;)%>'; frmUrlList.next_action.value='update record'; textSubmit('frmUrlList');&quot; class=&quot;half_button&quot;>
				<input type=&quot;button&quot; value=&quot;Delete&quot; onClick=&quot;frmUrlList.record_number.value='<%=rsGetList(&quot;urlPK&quot;)%>'; frmUrlList.next_action.value='delete record'; textSubmitCheck('frmUrlList');&quot; class=&quot;half_button&quot;>
			</td>
			
			<td>
				<a href=&quot;<%=rsGetList(&quot;url&quot;)%>&quot; class=&quot;my_a&quot;><%=rsGetList(&quot;websitename&quot;)%></a>
			</td>
			<td>
				<%=rsGetList(&quot;url&quot;)%>
			</td>
			
		</tr>
		<%
		rowCounter = rowCounter + 1
		rsGetList.MoveNext
	Loop
	%>
		<tr class=&quot;listRow<%=(rowCounter mod 2)%>&quot;>
			
			<td align=&quot;center&quot;>	<% ' code changes follow, use javascript textSubmitCheck for add to confirm %>
				<input type=&quot;button&quot; value=&quot;Add New Website&quot; onClick=&quot;frmUrlList.next_action.value='insert record'; textSubmitCheck('frmUrlList');&quot; class=&quot;full_button&quot; >
			</td>
				<td>
				<input type=&quot;text&quot; name=&quot;txtNewWebSite&quot; class=&quot;txtInput&quot; value=&quot;Add A New Web Site!&quot; size=&quot;20&quot;>
			</td>
			<td>
				<input type=&quot;text&quot; name=&quot;txtNewUrl&quot; class=&quot;txtInput&quot;  value=&quot;Put the Address Here! 	With Or Without The [URL unfurl="true"]http://&quot;[/URL] size=&quot;20&quot;>
			</td>
			
		</tr>
	</table>
	</form>
	<%
End Function


'********************************* Update Page **********************************
Function update_page

	Dim objCommand
	Dim sqlGetRecord
	Dim rsGetRecord
	
	sqlGetRecord = &quot;SELECT * FROM urllist WHERE urlPK = &quot;&Request.Form(&quot;record_number&quot;)
	
	on Error Resume Next
		Set objCommand = Server.CreateObject(&quot;ADODB.Command&quot;)
		objCommand.ActiveConnection = strConnect
		objCommand.CommandText=sqlGetRecord
		objCommand.CommandType=adCmdText
		Set rsGetRecord = objCommand.Execute
		Set objCommand = Nothing
	%>
	<form method=POST action=&quot;<%=page_name%>&quot; name=&quot;frmUpdateForm&quot; onSubmit=&quot;return confirm('Are you sure?');&quot;>
	<input type=&quot;hidden&quot; name=&quot;next_action&quot; value=&quot;update submit&quot;>
	<input type=&quot;hidden&quot; name=&quot;record_number&quot; value=&quot;<%=Request.Form(&quot;record_number&quot;)%>&quot;>
	<table class=&quot;urlListTable&quot;>
		<tr class=&quot;listRow0&quot;>
			<th>
				Website
			</th>
			<th>
				Address
			</th>
			<th>
				Option
			</th>
		</tr>
		<tr>
			<td>
				<input type=&quot;text&quot; name=&quot;txtWebSite&quot; value=&quot;<%=rsGetRecord(&quot;websitename&quot;)%>&quot; class=&quot;txtInput&quot; size=&quot;20&quot;>
			</td>
			<td>
				<input type=&quot;text&quot; name=&quot;txtUrl&quot; value=&quot;<%=rsGetRecord(&quot;url&quot;)%>&quot; class=&quot;txtInput&quot; size=&quot;20&quot;>
			</td>
			<td>
				<input type=&quot;submit&quot; value=&quot;Update!&quot;>
			</td>
		</tr>
	</table>
	</form>
	<%
End Function

'********************************* Update Submit ********************************
Function update_submit
	Dim objCommand
	Dim sqlUpdateRecord
	
	sqlUpdateRecord = &quot;UPDATE urllist SET url='&quot;&Request.Form(&quot;txtUrl&quot;)&&quot;', websitename='&quot;&Request.Form(&quot;txtWebSite&quot;)&&quot;' WHERE urlPK = &quot;&Request.Form(&quot;record_number&quot;)
	
	on Error Resume Next
		Set objCommand = Server.CreateObject(&quot;ADODB.Command&quot;)
		objCommand.ActiveConnection = strConnect
		objCommand.CommandText=sqlUpdateRecord
		objCommand.CommandType=adCmdText
		objCommand.Execute
		Set objCommand = Nothing
End Function

'********************************* Insert Record ********************************
Function insert_record
	Dim objCommand
	Dim sqlInsertRecord

	sqlInsertRecord = &quot;INSERT INTO urllist(url,websitename) values('&quot;&Request.Form(&quot;txtNewUrl&quot;)&&quot;', '&quot;&Request.Form(&quot;txtNewWebSite&quot;)&&quot;')&quot;

	on Error Resume Next
		Set objCommand = Server.CreateObject(&quot;ADODB.Command&quot;)
		objCommand.ActiveConnection = strConnect
		objCommand.CommandText=sqlInsertRecord
		objCommand.CommandType=adCmdText
		objCommand.Execute
		Set objCommand = Nothing
End Function

'********************************* Delete Record ********************************
Function delete_record
	Dim objCommand
	Dim sqlDeleteRecord

	sqlDeleteRecord = &quot;DELETE FROM urllist WHERE urlPK = &quot;&Request.Form(&quot;record_number&quot;)

	on Error Resume Next
		Set objCommand = Server.CreateObject(&quot;ADODB.Command&quot;)
		objCommand.ActiveConnection = strConnect
		objCommand.CommandText=sqlDeleteRecord
		objCommand.CommandType=adCmdText
		objCommand.Execute
		Set objCommand = Nothing
End Function

'********************************* The Real Thing *****************************
%>
<html>
<head>
	<title>Url List</title>
	<script language=&quot;JavaScript&quot;>
	<!--
	function textSubmit(form_obj_name){
	window.setTimeout(form_obj_name+'.submit()',1);
	}

	//Inside your script tags
	function textSubmitCheck(form_obj_name){
		if(confirm(&quot;Are you sure?&quot;)){					//if the click ok
			window.setTimeout(form_obj_name+'.submit()',1); //do the submit
		}
		else{									//if they hit cancel
			//I use eval here because I received the form_obj_name as a string
			//	rather than the object itself, eval takes a string and evaluates
			//	it as if it were a line of code.
			eval(form_obj_name+&quot;.next_action.value='show list';&quot;); //reset the next_action
		}
	}

	//-->
	</script>
	<style>		<% 'Styles!!! wheee. Should be self-explanatory, made a couple changes since first copy. %>
		.urlListTable{
			/*background:#00CCFF;*/
			border:1px solid #000000;
			padding:5px;
			width:100%;
			margin-top:30px;
		}
		.urlListTable th{
			/*background:#66AADD;		replaced by .headers class
			border-right:1px solid #666666;
			border-bottom:1px solid #666666;*/
			height:20px;
			width:100%;
		}
		.headers{
			background: #88CCFF;
			border-top:0px;
			border-left:0px;
			border-right:1px solid #666666;
			border-bottom:1px solid #666666;
			height:20px;	
			width:100%;
			color:#000000;
			text-decoration:none;
			padding-bottom:3px;   /* don't want it to make the size of the table cell change
									 object height = height + top border + bottom border + padding= 24 */
		}
		.headers:hover{
			background-color: #ff0011;
			border-top:1px solid #5599CC;
			border-left:1px solid #5599CC;
			border-right:2px solid #555555;
			border-bottom:2px solid #555555;
			padding-bottom:1px;   /* don't want it to make the size of the table cell change
									 object height = height + top border + bottom border + padding= 24 */
		}
		.listRow0{
			background-color:#cceeFF;
		}
		.listRow1{
			background-color:#DDffbb;
		}
		.listHead{
			font-size:32px;
			font-family: cursive;
			text-decoration: underline;
			background:#66AADD;
			border-right:1px solid #666666;
			border-bottom:1px solid #666666;
			height:50px;
			text-align:center;
		}
		.half_button{
			font-style:tahoma;
			font-size:10px;
			width:70px;
		}
		.full_button{
			font-style:tahoma;
			font-size:9px;		
			width:145px;
		}
		.txtinput{
			width:100%;
		}
		.pageLayout{
			width:95%;
			text-align:center;
			background:#eeeeee;
			height:100%;
			margin:0px;
		}
		.my_a{
			color:#114411;
			padding-left:5px;
			padding-right:5px;
		}
		.my_a:hover{
			color:#ffffff;
			background-color:#ff0011;
		}
	</style>
</head>
<body>
<center>
<div class=&quot;pageLayout&quot;>
<table class=&quot;urlListTable&quot;>
	<tr>
		<td class=&quot;listHead&quot;>
			The Url List
		</td>
	</tr>
</table>
<%

Select Case next_action
	Case &quot;show list&quot;
		show_list
	Case &quot;insert record&quot;
		insert_record
		show_list
	Case &quot;update record&quot;
		update_page
	Case &quot;update submit&quot;
		update_submit
		show_list
	Case &quot;delete record&quot;
		delete_record
		show_list
	Case Else
		%>
		<h1>Internal Error</h1>
		Please contact site administrator.<br>
		Error: Unknown Action Request<br>
		<a href=&quot;<%=page_name%>&quot;>Click here to return to the list</a>
		<%
End Select
%>
</div>
</center>
</html>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top