Solved

strip querystring paramters

Posted on 2013-01-29
3
166 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
Comment Utility
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
Comment Utility
"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
Comment Utility
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
css, html 6 29
Library to convert HTML to PDF. 8 42
javascript error when invoking bingmaps 13 15
HTML CSS 7 13
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …

762 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

8 Experts available now in Live!

Get 1:1 Help Now