title: Can I add a parameter to a form through Javascript?
body: <p>I have an HTML form that adds parameters to an URL. I only want the extra parameter added if a certain option is selected in the same form. So let's say I want to add the parameter "addedParameter=1" to the URL if "Commercial" is selected, otherwise I don't want the parameter to appear at all (other wise I get no results for "House" and "Land") Please let me know what I can do.</p>
  
  <pre><code>&lt;select id="pt" value="pt" name="pt" onChange="addParameter()"&gt;
  &lt;option value="" name=""&gt;Select&lt;/option&gt;
  &lt;option value="1" name="1"&gt;House&lt;/option&gt;
  &lt;option value="2" name="2"&gt;Commercial&lt;/option&gt;
  &lt;option value="3" name="3"&gt;Land&lt;/option&gt;
  &lt;/select&gt;
  
  &lt;input type="hidden" id="add" name="" value="1"&gt;
  
  function addParameter(){
  if(pt.selectedIndex == 1)
  document.getElementById("add").name = "addedParameter";
  }
  </code></pre>