Change URL Submitted to Depending on Form Selection
        Posted  
        
            by Chris
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Chris
        
        
        
        Published on 2010-05-06T17:48:29Z
        Indexed on 
            2010/05/06
            17:58 UTC
        
        
        Read the original article
        Hit count: 248
        
I have a form which I need to submit to one of three different URLs depending on a selection made in the form.
I suspect the easiest solution is to use jQuery to insert the appropriate path before the rest of the form parameters as the selection is made, but not sure on what the code would be. Any pointers greratly appreciated!
<form id="myForm" action='/booking/default-path' accept-charset='utf-8' method='get'>
  <select name="paramA" id="paramA">
    <option id="optionA" value="A" selected="selected">Option A</option>
    <option id="optionB" value="B">Option B</option>
  </select>
  <select name="currency" id="currency">
    <option id="GBP" value="GBP" selected="selected">British Pounds</option>
    <option id="EUR" value="EUR">Euros</option>
    <option id="USD" value="USD">US Dollars</option>
  </select>
<input type="submit" value="submit" id="submit" name="submit" />
</form>
Where the three different URLs would be:
../booking/default-path-gbp?...[params here]...
../booking/default-path-eur?...[params here]...
../booking/default-path-usd?...[params here]...
I know it would be a lot easier to incorporate the parameter in the usual way and just use one submission URL root, but unfortunately I'm submitting to an eComms system out of my control and am stuck with having to find a solution to this.
Should be easy I think, but not sure where to start, jQuery used elsewhere, so would prefer to use this framework in any solutions.
© Stack Overflow or respective owner