<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
     xmlns:admin="http://webns.net/mvcb/"
     xmlns:content="http://purl.org/rss/1.0/modules/content/"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
	<channel> 

	<title>Comments on: Building a URL with a Form via JavaScript?</title>
	<link>http://ask.metafilter.com/81760/Building-a-URL-with-a-Form-via-JavaScript/</link>
	<description>Comments on Ask MetaFilter post Building a URL with a Form via JavaScript?</description>
	<pubDate>Wed, 23 Jan 2008 12:26:01 -0800</pubDate>
	<lastBuildDate>Wed, 23 Jan 2008 12:26:01 -0800</lastBuildDate>
	<language>en-us</language>
	<docs>http://blogs.law.harvard.edu/tech/rss</docs>
	<ttl>60</ttl>

	<item>
		<title>Question: Building a URL with a Form via JavaScript?</title>
		<link>http://ask.metafilter.com/81760/Building-a-URL-with-a-Form-via-JavaScript</link>	
		<description>Anyone have a JavaScript trick to create a web form that builds a URL to send users to a pre-populated search? &lt;br /&gt;&lt;br /&gt; I&apos;m trying to build a form that can add various variables to a URL prior to submitting, conducting a search with prepopulated criteria.  For example, I&apos;d like the web form to say:&lt;br&gt;
&lt;br&gt;
&lt;blockquote&gt;Find: [ ] Widgets  [ ] Doodads  [ ] Gizmos&lt;br&gt;
Priced: [ ] Below $5  [ ] Below $500 [ ] Below $5000&lt;/blockquote&gt;&lt;br&gt;
&lt;br&gt;
The equivalent plain, non-trick HTML would look like this:&lt;br&gt;
&lt;br&gt;
&lt;blockquote&gt;&amp;lt;input type=&quot;checkbox&quot; name=&quot;type&quot; value=&quot;widgets&quot;&amp;gt;&lt;br&gt;
&amp;lt;input type=&quot;checkbox&quot; name=&quot;type&quot; value=&quot;doodads&quot;&amp;gt;&lt;br&gt;
&amp;lt;input type=&quot;checkbox&quot; name=&quot;type&quot; value=&quot;gizmos&quot;&amp;gt;&lt;br&gt;
&lt;br&gt;
&amp;lt;input type=&quot;checkbox&quot; name=&quot;maxprice&quot; value=&quot;0005&quot;&amp;gt;&lt;br&gt;
&amp;lt;input type=&quot;checkbox&quot; name=&quot;maxprice&quot; value=&quot;0500&quot;&amp;gt;&lt;br&gt;
&amp;lt;input type=&quot;checkbox&quot; name=&quot;maxprice&quot; value=&quot;5000&quot;&amp;gt;&lt;/blockquote&gt;&lt;br&gt;
&lt;br&gt;
But, instead of the form sending information the usual way, selecting the various elements would instead add, remove, or change variables within a URL to which it would send users when they clicked &quot;Submit.&quot;  For example, changing the above fields would, behind the scenes, build URLs like:&lt;br&gt;
&lt;br&gt;
&lt;blockquote&gt;http://www.search.com/query?maxprice=0005&lt;br&gt;
http://www.search.com/query?product=doodads&lt;br&gt;
http://www.search.com/query?product=doodads&amp;amp;maxprice=0500&lt;/blockquote&gt;&lt;br&gt;
&lt;br&gt;
Users could not select various fields without breaking the URL, but also combine any series of variables available.  Clicking submit would finalize the search URL and send them straight to the results. Presume that the receiving site would understand the variable names and values sent in the URL.&lt;br&gt;
&lt;br&gt;
This seems pretty straightforward, but I can&apos;t find example code to do exactly this.  Any pointers would be much appreciated!</description>
		<guid isPermaLink="false">post:ask.metafilter.com,2008:site.81760</guid>
		<pubDate>Wed, 23 Jan 2008 12:09:23 -0800</pubDate>
		<dc:creator>pzarquon</dc:creator>
		
			<category>html</category>
		
			<category>form</category>
		
			<category>forms</category>
		
			<category>javascript</category>
		
			<category>web</category>
		
	</item> <item>
		<title>By: breaks the guidelines?</title>
		<link>http://ask.metafilter.com/81760/Building-a-URL-with-a-Form-via-JavaScript#1211542</link>	
		<description>Umm, I may be confused, but what you&apos;re describing looks exactly like the normal form behaviour when the request method is &lt;var&gt;GET&lt;/var&gt;.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.81760-1211542</guid>
		<pubDate>Wed, 23 Jan 2008 12:26:01 -0800</pubDate>
		<dc:creator>breaks the guidelines?</dc:creator>
	</item><item>
		<title>By: breaks the guidelines?</title>
		<link>http://ask.metafilter.com/81760/Building-a-URL-with-a-Form-via-JavaScript#1211547</link>	
		<description>That is to say, if your plain-vanilla HTML form looks something like this:&lt;br&gt;
&lt;br&gt;
&lt;code&gt;&amp;lt;form method=&quot;GET&quot; action=&quot;http://www.search.com/query&quot;&amp;gt;&lt;br&gt;
&amp;lt;input type=&quot;checkbox&quot; name=&quot;type&quot; value=&quot;widgets&quot;&amp;gt;&lt;br&gt;
&amp;lt;input type=&quot;checkbox&quot; name=&quot;type&quot; value=&quot;doodads&quot;&amp;gt;&lt;br&gt;
&amp;lt;input type=&quot;checkbox&quot; name=&quot;type&quot; value=&quot;gizmos&quot;&amp;gt;&lt;br&gt;
&lt;br&gt;
&amp;lt;input type=&quot;checkbox&quot; name=&quot;maxprice&quot; value=&quot;0005&quot;&amp;gt;&lt;br&gt;
&amp;lt;input type=&quot;checkbox&quot; name=&quot;maxprice&quot; value=&quot;0500&quot;&amp;gt;&lt;br&gt;
&amp;lt;input type=&quot;checkbox&quot; name=&quot;maxprice&quot; value=&quot;5000&quot;&amp;gt;&lt;br&gt;
&amp;lt;input type=&quot;submit&quot;&amp;gt;&lt;br&gt;
&amp;lt;/form&amp;gt;&lt;/code&gt;&lt;br&gt;
&lt;br&gt;
Then the form variables are appended to the form&apos;s &lt;var&gt;action&lt;/var&gt; URI when the user submits the form.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.81760-1211547</guid>
		<pubDate>Wed, 23 Jan 2008 12:30:13 -0800</pubDate>
		<dc:creator>breaks the guidelines?</dc:creator>
	</item><item>
		<title>By: pzarquon</title>
		<link>http://ask.metafilter.com/81760/Building-a-URL-with-a-Form-via-JavaScript#1211555</link>	
		<description>I think I understand what you&apos;re saying, but... does the GET method assemble the URL on the client side and submit it?  Or is it still submitting the individual variables to the search application on the remote site?&lt;br&gt;
&lt;br&gt;
Basically we&apos;re working with a custom search application that has its own forms doing things in .NET, but that the developers have built so that we can build a URL to get a search result with one click.&lt;br&gt;
&lt;br&gt;
http://www.search.com/query?product=doodads&amp;amp;maxprice=0500&amp;amp;location=us&amp;amp;vendorid=4159&lt;br&gt;
&lt;br&gt;
In other words, if I clicked that link I&apos;d get my results on their site.  Apart from using the integrated search form, using URLs like that is the only way I know how to preset variables in a search from outside.  I thought I&apos;d need a Javascript code to put the pieces together, but if not, do tell!  And... well, obviously, 101-level tutorial sites or example code would be much appreciated.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.81760-1211555</guid>
		<pubDate>Wed, 23 Jan 2008 12:35:46 -0800</pubDate>
		<dc:creator>pzarquon</dc:creator>
	</item><item>
		<title>By: pzarquon</title>
		<link>http://ask.metafilter.com/81760/Building-a-URL-with-a-Form-via-JavaScript#1211556</link>	
		<description>Oops. I posted my response to your one-line reply, and you&apos;ve gone ahead and given me the code in the mean time. I&apos;ll try that!</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.81760-1211556</guid>
		<pubDate>Wed, 23 Jan 2008 12:36:26 -0800</pubDate>
		<dc:creator>pzarquon</dc:creator>
	</item><item>
		<title>By: breaks the guidelines?</title>
		<link>http://ask.metafilter.com/81760/Building-a-URL-with-a-Form-via-JavaScript#1211567</link>	
		<description>Yes, the URI for the GET is assembled by the browser on the client side, including the form variables.  However, I don&apos;t understand your question, &quot;is it still submitting the individual variables to the search application on the remote site?&quot;&lt;br&gt;
&lt;br&gt;
Ignoring cookies, in a GET request, the only input to the remote application is the URI.  It&apos;s up to the remote application to interpret the meaning of any variables in the query portion of the URI.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.81760-1211567</guid>
		<pubDate>Wed, 23 Jan 2008 12:46:47 -0800</pubDate>
		<dc:creator>breaks the guidelines?</dc:creator>
	</item><item>
		<title>By: pzarquon</title>
		<link>http://ask.metafilter.com/81760/Building-a-URL-with-a-Form-via-JavaScript#1211568</link>	
		<description>It worked! Of course I was thinking immediately, &quot;You&apos;d think this is how forms should work in the first place.&quot; And they do. And I&apos;m an doofus. I shudder to imagine what madness I&apos;d descend into if I tried to recreate this with JavaScript or something even more pointless. Thanks!</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.81760-1211568</guid>
		<pubDate>Wed, 23 Jan 2008 12:48:50 -0800</pubDate>
		<dc:creator>pzarquon</dc:creator>
	</item>
	</channel>
</rss>
