vendredi 27 février 2015

Form Dropdown Select Link

I have a select drop down, once user specifies the brand I want it to link over in 2 new tabs for the 2 URLs. How can I do this, is it best to do onclick event for submit and then run a function with "if and else" through the selects..any suggestions? Here is my current code.



<fieldset>

<legend><span class="number">1</span>Select a Brand</legend>

<label for="Brand">Brand:</label>
<select id="brandSelect" name="brand_select">
<optgroup label="Grills">
<option value="http://site1.com", "http://site1A.com">DCS</option>
<option value="http://site2.com", "http://site2A.com">Alfresco</option>
<option value="http://site3.com", "http://site3A.com">Viking</option>
<option value="http://site4.com", "http://site4A.com">Fire Magic</option>
<option value="http://site5.com", "http://site5A.com">Lynx</option>
<option value="http://site6.com", "http://site6A.com">Coyote</option>
</optgroup>
</select>

</fieldset>

<button type="submit">Sign Up</button>
<script type="text/javascript">
var urlmenu = document.getElementById( 'brandSelect' );
urlmenu.onchange = function() {
window.open( this.options[ this.selectedIndex ].value );
};
</script>

Aucun commentaire:

Enregistrer un commentaire