mercredi 25 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 a new tab to the page specified in the value. This works fine with 1 URL in the value but what if I wanted 2 tabs to open with 2 different URLs..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">DCS</option>
<option value="http://site2.com">Alfresco</option>
<option value="http://site3.com">Viking</option>
<option value="http://site4.com">Fire Magic</option>
<option value="http://site5.com">Lynx</option>
<option value="http://site6.com">Coyote</option>
</optgroup>
<optgroup label="Outdoor Furniture">
<option value="http://site7.com">Breezesta</option>
<option value="http://site8.com">Polywood</option>
<option value="http://site9.com">Malibu</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