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

Clearing a QueryString

Status
Not open for further replies.

AndyApp

Programmer
Dec 20, 2001
259
GB
Hi all,

I have a page that passes a number of variables to another page which re-queries a SQL database depending on those variables and displays the results.

The problem is that the user can then make changes to those results on the page, or at least they should be able to but because the variables are still in the address bar (i.e. it seems they can't as it defaults to the record taken from the database and doesn't update.

I think i need to remove everything after and including '?' but don't know how to. Basically i need to clear the querystring.

Any ideas? "Life is like a Ferrari, it goes to fast.
But that's ok, because you can't afford it anyway" - Jim Davis (Garfield)
 
Code:
<a href='<%=request.servervariables(&quot;SCRIPT_NAME&quot;)%>'>Link</A>
... might have the desired effect... This is not a bug - it's an undocumented feature...
;-)
 
Jonax,

yes that does work but a little too well. It clears all the results from my drop down boxes and text boxes, which isn't much good really.

I need to remove the querystring probably as the page is being wrote to the screen. &quot;Life is like a Ferrari, it goes to fast.
But that's ok, because you can't afford it anyway&quot; - Jim Davis (Garfield)
 
Where do you get the results for your dropdowns and textboxes???
Is it based on the queryparametres?
Maybe you could do it with POSTed formfields?
I don't think you can alter the contents of the location-bar after loading the page... This is not a bug - it's an undocumented feature...
;-)
 
It sounds like you are looking to re-query the database depending on a users selection from their first query. If you submit the page again than the querystring should reflect the selections the user just made instead of the selections made on the previous page. This way you can query the db for the newer information. you shouldn't have to clear the querystring yourself, it only holds data for one page load than disappears forever. The address displayed in the URL on the page you are working on should not affect the next page unless you are writing those exact values back into your form and not allowing them to be updated.
-Tarwn &quot;The problem with a kludge is eventually you're going to have to back and do it right.&quot; - Programmers Saying (The Wiz Biz - Rick Cook)
&quot;Your a geek!&quot; - My Girlfriends saying
 
Tarwn,

You may have it i'm not sure, can't quite get my head round what it is your actually saying. (I knew that pint at lunch time was a mistake)

Here's what happens:

Search.asp - User selects a single or a number of options to search for a particular record. The page uses a DLL to query a SQL database and displays just enough results from each record so the user can distinguish them. The reference number is displayed and added to a querystring along with a function set to true.

worklogger.asp - Checks to see if the function is true, if so then the user has come from the search page and it then takes the reference number from the querystring and re-querys the DLL and displays the full set of results for that record. If the function is empty then the page just opens and alows the user to enter a new record.

Once the user has a record being displayed from the search page they can then edit it. One of the fields is a yes or no field wich is set to no usually. If the user has completed the job displayed they select yes, this fires a function which time stamps another field in the database. However it doesn't work, the page refreshes with the orignal data still in, it doesn't update the database or display.

Long winded i know but hopefully this helps you understand the problem i'm having. There are a number of these boxes that fire changes and none work. &quot;Life is like a Ferrari, it goes to fast.
But that's ok, because you can't afford it anyway&quot; - Jim Davis (Garfield)
 
You say it &quot;fires a function...&quot; is this on the same page or after the page re-submits? Could you show me a portion of this file so I can get a better idea?
-Tarwn &quot;The problem with a kludge is eventually you're going to have to back and do it right.&quot; - Programmers Saying (The Wiz Biz - Rick Cook)
&quot;Your a geek!&quot; - My Girlfriends saying
 
These are some of the functions that fire from drop down boxes using the onchange event. They are on the same page as the dropdown boxes ABOVE the <HTML> tag. They might not mean an awful lot to you, unfortunatly the page is HUGE i.e. 3495 lines in InterDev! so it's a bit impractical to display it all.

<%
Function Completed_onchange()
'This function places the formatted date into the disabled WorkCompleted textbox only if
'someone has selected Y from the Completed textbox.
strFormTime = Date()
strFormTime = FormatDateTime(strFormTime, 2)
if (Completed.getText(Completed.selectedIndex)) = &quot;Y&quot; then
WorkCompleted.value = strFormTime
else
WorkCompleted.value = &quot;&quot;
end if
end function
%>
<%
Function Client_onchange()
'This function makes sure that if Client is selected then NonClient is blank.
if (Client.getText(Client.selectedIndex)) = &quot;&quot; then
else
NonClient.selectByValue(0)
end if
end function
%>
<%
Function NonClient_onchange()
'This function makes sure that if NonClient is selected then Client is blank.
if (NonClient.getText(NonClient.selectedIndex)) = &quot;&quot; then
else
Client.selectByValue(0)
end if
end function
%>
<%
Function Allocated_onchange()
'This function makes sure that if a name is selected then the team is blank in the allocated
'to part.
if (Allocated.getText(Allocated.selectedIndex)) = &quot;&quot; then
else
Allocated2.selectByValue(0)
end if
end function
%>
<%
function Allocated2_onchange()
'This function makes sure that if a team is selected then the name is blank in the allocated
'to part.
if (Allocated2.getText(Allocated2.selectedIndex)) = &quot;&quot; then
else
Allocated.selectByValue(0)
end if
end function
%> &quot;Life is like a Ferrari, it goes to fast.
But that's ok, because you can't afford it anyway&quot; - Jim Davis (Garfield)
 
Ok, the problem is that you are trying to call server side functions from client side events. This won't work. Once the server has finished executing the code and sends the html to the client than it clears the memory and exits. By the time the client starts looking at the page and interacting with it, the server side code is no longer in existence. What you will need to do is pass your information in form fields to the next page (this page) and do some checks to see which functions to call or which values to write. So when you are getting ready to write the disabled date text box you would do something like:
Code:
<input type=&quot;text&quot; name=&quot;WorkCompleted&quot; disabled<%
If Request.Form(&quot;Completed&quot;) = &quot;Y&quot; Then
   Response.Write &quot;value='&quot;&FormatDateTime(Now,2)&&quot;'&quot;
End If
%>>
rather than write a function like the one above.

You would want to do your database update before this, the simplest way is to update all the fields in the db for this record from the ones on the page (using Request.Form) rather than checking each to see if it changed.

You will always have to submit a form back to the server to use client side data to perform server side operations.

-Tarwn &quot;The problem with a kludge is eventually you're going to have to back and do it right.&quot; - Programmers Saying (The Wiz Biz - Rick Cook)
&quot;Your a geek!&quot; - My Girlfriends saying
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top