Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

pass a query string on a buttonclick

Posted on 2001-09-14
6
Medium Priority
?
227 Views
Last Modified: 2008-02-01
I have a query string and when i click a button, that query string should be passed as a URL for the next page in the same window... Using ......

Window.Location.href="asp1.asp?Title=<% =Request.QueryString("xyz") %>

This is an example of how i tried for a Title field from a database.

the error i encountered was "Unterminated String Constant"...

The eror code is 1033. I hope iam correct...If anyone can help me sure do mail me soon........


S.Ramanujam (ramanujam@clearexperts.com)clearExpertsSolutions (p) Ltd,
A3, "CEEBROS RANGAM",
No.11, Cenatoph Road,
Teynampet, Chennai - 18

Phone: +91-44-4334619(off)
       +91-44-4334634(off)
       +91-44-3722375(res)

0
Comment
Question by:ramanujamsampath
6 Comments
 
LVL 3

Expert Comment

by:bigbed
ID: 6482346
You have href="....
then you have another double-quoted string within it ("xyz"), and you don't have the terminating double-quote for the href attribute.

You need to escape the double-quotes in the QueryString("xyz") call, or use single-quotes there. And you need to add the closing double-quote.
Example using single-quote inside double-quotes (assuming single-quotes are legal in your ASP):
Window.Location.href="asp1.asp?Title=<% =Request.QueryString('xyz') %>"

0
 
LVL 5

Expert Comment

by:aryumin
ID: 6482364
Window.Location.href="asp1.asp?Title=<% =Server.URLEncode(Request.QueryString("xyz")) %>
0
 
LVL 5

Expert Comment

by:aryumin
ID: 6482372
Oops. Forget a closing quote :(
Window.Location.href="asp1.asp?Title=<% =Server.URLEncode(Request.QueryString("xyz")) %>";
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 200 total points
ID: 6482846
and to make it valid javascript you need to lowercase it and href is not needed to SET the url:
window.location="asp1.asp?Title=<% =Server.URLEncode(Request.QueryString("xyz")) %>";

Michel
0
 

Author Comment

by:ramanujamsampath
ID: 6486651
Thanx a lot for a wonderful answer..... It really worked at the first trial itself...

Ai. Alevidae
Cheers

S.Ramanujam (ramanujam@clearexperts.com)clearExpertsSolutions (p) Ltd,
A3, "CEEBROS RANGAM",
No.11, Cenatoph Road,
Teynampet, Chennai - 18

Phone: +91-44-4334619(off)
       +91-44-4334634(off)
       +91-44-3722375(res)

0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 6486945
Sorry guys - just making a comment - not trying to poach the question

Michel
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

810 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