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

How to pull querystring into JS? 2

Status
Not open for further replies.

Mojojojo

Programmer
Joined
Jun 25, 2001
Messages
11
Location
US
Thanks to vituz and dianal for helping me to this point...

I am stuck on a couple of simple things. I am trying to pull the querystring so that I can use it in javascript. My method below is not working. It is an ASP page.
When I use this from within a page and not the querystring it works ( I change the var object statement ).

I am opening a new page in the querystring and doing the below actions.

Any ideas of what I am doing wrong?

Thanks, (I vote positive for even remote assistance)

Joe

<SCRIPT LANGUAGE=JavaScript>

var object = <% Request.Querystring %>
var str=object.innerHTML;
document.write(str);
</script>
 
Hi joe,

I've adjusted your script just a bit.

Suppose you have an url like this one:
somepage.asp?text=sometext

<script language=&quot;JavaScript&quot;>
var str = <%=Request.QueryString(&quot;text&quot;)%>
document.write(str)
</script>

This should do it. Hope it does? :-P

Kristof
 
Sorry, made a small error.

Forgot the '

<script language=&quot;JavaScript&quot;>
var str = '<%=Request.QueryString(&quot;text&quot;)%>'
document.write(str)
</script>

Bye ;-)
 
hi!
first of all, u're wellcome
then, a bit closer 2 ur subject:
i havent messed so far with asp, but as far as i kno, u can get query string this way:
var str=location.search

but i bet u knew that..
anyway, this forum has a FAQ on this subject:


regards, vic
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top