Home     Articles & Projects     Products & Web Services     Forum

Form query

Hi David,

Im after a little help as i have searched the net and cant find anything!

I want a form with drop down options (i can manage this) and each option would build part of the final url to visit.

so for example first option i pick fashion , so this would dictated the merchant , so this option would point to NEWLOOK.co.uk , then the second option i might have categories of clothing , so i pick jumpers , so the url will now point to NEWLOOK.co.uk/jumpers , and so on.

so would you know an easy way i could achieve this?

thanks in advance

Hi Jonny, This should be

Hi Jonny,

This should be possible using JavaScript; where selecting each option modifys the action='' attribute of the form; for example:

  <form name='myform' action=''>
  <select id='website' name='website' onchange='JavaScript:updateForm();'>
    <option value='http://www.example.com/'>Example.com</option>
    <option value='http://www.example.net/'>Example.net</option>
  </select>
  <select id='category' name='category' onchange='JavaScript:updateForm();'>
    <option value='jumpers'>Jumpers</option>
    <option value='jeans'>Jeans</option>
  </select>
  <input type='submit' value='Go' />
  </form>
  <script type='text/javascript'>
  function updateForm()
  {
    var url = document.getElementById("website").value + document.getElementById("category").value;
    document.myForm.action = url;
  }
  </script>

Hope this helps!
Cheers,
David.

perfect ,

perfect ,