views:

106

answers:

5

I just want to know whether there is a way to answer this question with "Yes" without using JavaScript.

What I want to do is have a search form that automatically generates URLs like http://example.com/search/my+search+term or something similar when I enter my search term into a search text field.

EDIT: Due to some mis-understanding (and not being clear on my part), a clarification: I want the browser to generate that URL based on the value of the text field when the form is submitted.

+3  A: 

No, it's not possible without using JavaScript.

The best you can do is using a GET action and have an url like http://example.com/search/?q=my+search+term, where q is the name of the input search box.

Wookai
BTW this is kind of what google does ;) : http://www.google.com/search?q=my+search+term !
Wookai
A: 

Yes you could perform something like this server-side pretty easily as long as you don't mind submitting a form.

EDIT: Upon further clarification from the author in comments below: It is not possible in a pure client-side manner without JavaScript or some other client-side tool like Flash/Silverlight (which is admittedly overkill).

Scott Anderson
I don't think this is the answer to the question that is being asked.
T. Stone
Huh? How does that help me when the form is submitted either via POST or GET?
Franz
How is it not an answer? I could write a python or php script to do this right now. He asked if he could generate a URL like that as the result of a search form, and it's 100% possible.
Scott Anderson
In that case I am sorry for not making it perfectly clear. I wanted the browser to generate the URL that way when sending the form.
Franz
If you want the browser to generate it without using JavaScript, the answer is no, unless you want to use some other client side technology like Flash or Silverlight which is pretty overkill.
Scott Anderson
Yup. Thought so. Edit your answer and I'll remove the downvote (can't do so otherwise) ;)
Franz
okay it's been edited.
Scott Anderson
-(-1). I guess that's only fair ;)
Franz
A: 

The answer is No

cx0der
+1. It's all I asked for and thus you should at least not get a downvote for this ;)
Franz
@Franz Thanks mate :)
cx0der
thats great attitude .. I should say .. :-)
infant programmer
A: 

No if you want it to be client side, if you can do it server side (by submitting the form) you can use something like PHP

Aly
Well, the action URL gets created on the client side...
Franz
+1  A: 

Using html only, no.

You could have something server side that might work. You could have the server respond with a 302 response code. If you are using Apache, you could probably use mod_rewrite to take the GET request and generate a new url.

For example, the browser might ask for http://example.com/search/?q=blah+foo+bar, the server could then take that and send the browser a 302 redirect for http://example.com/search/blah+foo+bar.

See more information at the Apache url rewriting guide, or by using your favorite search engine.

You could still use javascript to generate the correct url, but if someone has javascript disabled, this would work as a fallback.

Buddy