Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 179
  • Last Modified:

strip querystring paramters

I'm using Spry Accordion panels in a Classic ASP environment:

http://66.29.212.9/neweragems2012/checkout.asp

I need to navigate between panels based on user input. I can do this as long as the url query string is clear.

If you look at the above example and invoke the Continue button under the Checkout Method panel. The next panel opens as it should. Now there is a query sting added to the url( ?panel=1#Accordion1)

If you go back to the Checkout Method panel and try to start again the with the Continue button, the open panel fails.

It looks like the failure is because of the query string parameters.
So... is there a way to clear the query string parameters after invoking the continue button? Or is there a better way in general?

Also, is there a way to not have the page go to the top after clicking the Continue button?
0
webdork
Asked:
webdork
  • 2
1 Solution
 
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
it is because of whatever you are doing in your asp code.

The better way of managing the panels are in the javascript.  

You are trying to mix up asp/vb code from the server with js code running in the browser.  

Really you would should be writing ajax  posts and using javascript to check where the user should be to open and close tabs and not using page refreshes.

Try placing

   function visitPage(){
        window.location='http://66.29.212.9/neweragems2012/checkout.asp?panel=1#Accordion1';
    }


in the head section or before the <body>
0
 
webdorkAuthor Commented:
"it is because of whatever you are doing in your asp code."

that's not answer that tells me anything.
0
 
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
Sometimes the answer is just an answer and not necessarily exactly what your looking for.

I do recognize what you are doing though and that is trying to manipulate what should be done in the browser on the server.  In other words, you are trying to manipulate the functions of the accordion by rendering html from your asp code which runs on the server.  Instead, you should manipulate the javascript functions (spry) in the browser through javascript.

The way an asp page (or php) works is before the page loads, any calculations are done between your <% %> tags.  So if you have <%="<div id=""stuff"">one plus one is "&1+1&"</div>  <script>
document.getElementById(""stuff"").innerHTML=""5 is a better number!"";
</script>"%>

before the page loads, the server interprets that code and displays on the page as follows:

 <div id="stuff"> one plus one is 2 </div>

After all the rendered html loads, any javascript gets fired.  So what you actually will see is

 <div id="stuff"> 5 is a better number </div>

because the javascript ran the code

document.getElementById("stuff").innerHTML="5 is a better number!"

which was written by our asp code.

With javascript code, we can type things into the browser or click on something and the javascript will detect the click and can be programmed do do something.  In contrast, your asp code is run on the server and once the page is displayed, the asp code is no longer available UNLESS you submit a form or refresh the page and there is some query string to interpret.

Now that we have cleared up the difference between how your server side asp code runs vs client javascript (spry) we need to work on how you are manipulating your panels.  They are meant to be manipulated by javascript.  Your button is throwing a querystring which produces html from your asp code.  As I said, once it runs it is done and that is why you are having issues.  

Did you try my  suggestion of moving the function <script>function visitPage(){... .</script> to the head section of your page?

If that does not work the way I would work this is to use ajax posts, that can retrieve data  through an httpxml post and manipulate the panels using javascript giving your user a better experience.

Another option which may be easier to  understand is to make each button submit a form or page refresh with a querystring.  Then use your asp code to write javascript like:

<%
if request.querystring("tab")="1" then

   response.write "<script>//function to open up tab 1</script>"
end if
%>
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now