By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,694 Members | 1,795 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,694 IT Pros & Developers. It's quick & easy.

Need Some Help With Query Processing

P: n/a
Hi.

I need some help with structuring my query strings.

I have a form with a search bar and some links. Each
link is a search type (such as "community"). The HREF
for the link's anchor looks like the following:

<a href="?searchtype=2">Community</a>

When the user clicks on the Community search type, the query string
looks like:

http://www.domain.com/test.htm?searchtype=2

Then, he puts in his search string, such as "babysitters
in los angeles".

I want the string to look like the below before the form
is posted:

http://www.domain.com/test.htm?searc...in+los+angeles

But it looks like:

http://www.domain.com/test.htm?query...in+los+angeles

How do i get the querystring to "add" the query to the searchtype and
not "replace" the searchtype with the query?

I thank you.

Aug 29 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On Aug 29, 10:38 pm, pbd22 <dush...@gmail.comwrote:
Hi.

I need some help with structuring my query strings.

I have a form with a search bar and some links. Each
link is a search type (such as "community"). The HREF
for the link's anchor looks like the following:

<a href="?searchtype=2">Community</a>

When the user clicks on the Community search type, the query string
looks like:

http://www.domain.com/test.htm?searchtype=2

Then, he puts in his search string, such as "babysitters
in los angeles".

I want the string to look like the below before the form
is posted:

http://www.domain.com/test.htm?searc...itters+in+los+...

But it looks like:

http://www.domain.com/test.htm?query...in+los+angeles

How do i get the querystring to "add" the query to the searchtype and
not "replace" the searchtype with the query?

I thank you.
You can't do it like this. You need to get the existing query, add a
new string and pass it to the new url.

For example,

string new_url =
"http://www.domain.com/test.htm?searchtype="
+ Request.QueryString["searchtype"]
+ "&"
+ "query=" + Request.QueryString["query"];

Aug 29 '07 #2

P: n/a
On Aug 29, 3:33 pm, Alexey Smirnov <alexey.smir...@gmail.comwrote:
On Aug 29, 10:38 pm, pbd22 <dush...@gmail.comwrote:
Hi.
I need some help with structuring my query strings.
I have a form with a search bar and some links. Each
link is a search type (such as "community"). The HREF
for the link's anchor looks like the following:
<a href="?searchtype=2">Community</a>
When the user clicks on the Community search type, the query string
looks like:
http://www.domain.com/test.htm?searchtype=2
Then, he puts in his search string, such as "babysitters
in los angeles".
I want the string to look like the below before the form
is posted:
http://www.domain.com/test.htm?searc...itters+in+los+...
But it looks like:
http://www.domain.com/test.htm?query...in+los+angeles
How do i get the querystring to "add" the query to the searchtype and
not "replace" the searchtype with the query?
I thank you.

You can't do it like this. You need to get the existing query, add a
new string and pass it to the new url.

For example,

string new_url =
"http://www.domain.com/test.htm?searchtype="
+ Request.QueryString["searchtype"]
+ "&"
+ "query=" + Request.QueryString["query"];
OK, thanks. I guess I am still a little confused.

Doesn't your response imply that the querystring is already well
formed?
I would need searchtype and query in he querystring to be able to call
Request.QueryString["searchtype"] or Request.QueryString["query"] .
If you mean to pull this information from the querystring prior to
submitting
the form, I still don't understand how the querystring gets formed. It
does,
however, make more sense to simply take local variables where
searchtype and query are stored and construct the querystring from
that - if that is OK.

I am assuming that the new_url string you have is what would be
created
when the form is submit? Would you mind showing me how, exactly, the
new string would get passed to the next page? Filling out the script
would be helpful to me. below is my form with my query input box:

<form id="searchWidget">
<span>&nbsp;</span>
<input class="query" size="40"
name="query" type="text">
<input class="submit" value="Search"
type="submit">
<a class="adv" href="/
index.master_search.aspx?a=a&amp;x=1">Advanced Search</a>
<span>&nbsp;</span>
</form>

Thanks and apologies for my continued confusion here.

Aug 31 '07 #3

P: n/a
On Aug 31, 5:05 pm, pbd22 <dush...@gmail.comwrote:
On Aug 29, 3:33 pm, Alexey Smirnov <alexey.smir...@gmail.comwrote:


On Aug 29, 10:38 pm, pbd22 <dush...@gmail.comwrote:
Hi.
I need some help with structuring my query strings.
I have a form with a search bar and some links. Each
link is a search type (such as "community"). The HREF
for the link's anchor looks like the following:
<a href="?searchtype=2">Community</a>
When the user clicks on the Community search type, the query string
looks like:
>http://www.domain.com/test.htm?searchtype=2
Then, he puts in his search string, such as "babysitters
in los angeles".
I want the string to look like the below before the form
is posted:
>http://www.domain.com/test.htm?searc...itters+in+los+...
But it looks like:
>http://www.domain.com/test.htm?query...in+los+angeles
How do i get the querystring to "add" the query to the searchtype and
not "replace" the searchtype with the query?
I thank you.
You can't do it like this. You need to get the existing query, add a
new string and pass it to the new url.
For example,
string new_url =
"http://www.domain.com/test.htm?searchtype="
+ Request.QueryString["searchtype"]
+ "&"
+ "query=" + Request.QueryString["query"];

OK, thanks. I guess I am still a little confused.

Doesn't your response imply that the querystring is already well
formed?
I would need searchtype and query in he querystring to be able to call
Request.QueryString["searchtype"] or Request.QueryString["query"] .
If you mean to pull this information from the querystring prior to
submitting
the form, I still don't understand how the querystring gets formed. It
does,
however, make more sense to simply take local variables where
searchtype and query are stored and construct the querystring from
that - if that is OK.

I am assuming that the new_url string you have is what would be
created
when the form is submit? Would you mind showing me how, exactly, the
new string would get passed to the next page? Filling out the script
would be helpful to me. below is my form with my query input box:

<form id="searchWidget">
<span>&nbsp;</span>
<input class="query" size="40"
name="query" type="text">
<input class="submit" value="Search"
type="submit">
<a class="adv" href="/
index.master_search.aspx?a=a&amp;x=1">Advanced Search</a>
<span>&nbsp;</span>
</form>

Thanks and apologies for my continued confusion here.- Hide quoted text -

- Show quoted text -
I thought you are talking about ASP.NET. The form you have here is not
a server form (runat="server") and you cannot use my example with
Request.QueryString. Either, you have to use a javascript to build url
and redirect to it, or you can use GET method for example

<form action="/index.master_search.aspx" method="GET">
<input class="query" size="40" name="query" type="text">
<input type="hidden" name="searchtype" value="2"
<input class="submit" value="Search" type="submit">
</form>

When you type "blabla" in the text field and submit the form you would
be redirected to

/index.master_search.aspx?query=blabla&searchtype=2

Aug 31 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.