0

I have a section on a webapp where the user can search a map for a set of locations and it all works properly but I want the text of the location to show up in the URL so that the user can copy it and share it and it will be the same search.

What is the best way to do this and can I do it with HTML or do I need to use Javascript? I am using jinja2 as a templating engine and I am doing the back end in Python but that shouldn't have a big impact on this. Basically I want them to be able to search for "New York City, NYC" and I want it to show up in the URL as something like

www.url.com/map?location=new%20york%20city%20nyc

1
  • are you doing searches on client side, because if search string is submitted to server it is no brainer just do a GET submit of form Commented Oct 25, 2012 at 20:38

2 Answers 2

5

The simplest way is just to create a form:

<form action="/map" method="get">
<label>Search: <input type="search" placeholder="Search" name="location"></label>
<input type="Submit">
</form>

When you enter a search term into the input box and hit "Submit" the browser will make a request to http://www.your-site.com/?q=Your%20Search%20Term - and then you can get the argument from request and do whatever you need to do with it.

Sign up to request clarification or add additional context in comments.

1 Comment

ah that was much easier than I thought. I just needed to change the form from post to get and it worked. thanks for the clear explaination
0
document.location.hash = "some/values/moreValues";

And you can parse the hash when the page loads to display the content you need on the map

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.