Solved

strip querystring paramters

Posted on 2013-01-29
3
167 Views
Last Modified: 2013-02-02
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
Comment
Question by:webdork
  • 2
3 Comments
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
ID: 38832081
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
 

Author Comment

by:webdork
ID: 38844838
"it is because of whatever you are doing in your asp code."

that's not answer that tells me anything.
0
 
LVL 52

Accepted Solution

by:
Scott Fell,  EE MVE earned 500 total points
ID: 38845116
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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
This article discusses four methods for overlaying images in a container on a web page
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now