HTML and js with option value usage

CarinnaFitness

New Member
I have first a with 3 option value in it. When I select one of the values, I want it to remember which one I picked and once I press my button the javascript will open a specific url.Some code sample.\[code\] <select id="dd-files"> <option value="http://stackoverflow.com/questions/14578081/asdf">Pick:</option> <option value="http://stackoverflow.com/questions/14578081/url1">File1</option> <option value="http://stackoverflow.com/questions/14578081/url2">File2</option> <option value="http://stackoverflow.com/questions/14578081/url3">File3</option> </select> </section> </div><br> <div class="modal-footer"> <a class="btn btn-primary get-data" href="http://stackoverflow.com/questions/14578081/#">Button</a> </div>\[/code\]javascript This javascript directily just to know how it all works, so I just tested it. \[code\]$(".get-data").on("click",function() { var location = 'http://hardcodedurl.com'; window.open(location);\[/code\]Then I have another function, which when I pick one option value, stores it and open it directly, but instead of open it directly, I would like my second script just to open when my button ".get-data" is pressed.\[code\]$(function () { $('#dd-files').on('change', function() { debugger; var url = $(this).val(); if (url) { window.location = url; } return false; })})\[/code\]Any advice for a newbie?
 
Back
Top