Three Select Boxes Interacting To Yield One Result - Html, Javascript Or Jquery March 31, 2024 Post a Comment I have three select boxes: Select Productstring1<Solution 1: jsFiddle Demo$(function() { var downloadButton = $( selector-for-your-button ); $(downloadButton).click(function() { download_file( $('#one').val(), $('#two').val(), $('#three').val()); }); }); functiondownload_file(product_id, version_id, arch_id) { // if any of them is default, cancel (use or ||)if (product_id == 'default' || version_id == 'default' || arch_id == 'default') { alert("choose stuff!"); return; } elseif (product_id != 'default') { //window.location = 'mysite.com/download/Install_' +// product_id + '_' + version_id + '_' + arch_id + '.exe';console.log(product_id + '_' + version_id + '_' + arch_id + '.exe'); } } CopySolution 2: You can do something like this using jQuery's .map() function// check if all three select has a value selected besides default - return false if any are defaultif ($('select').filter(function() { returnthis.value == 'default'; }).length > 0) { returnfalse; } // using jQuery's map function - get the values - turn into array - join with '_'var newString = $('select').map(function(i, v) { return v.value; }).get().join('_'); console.log(newString); Copyhttp://jsfiddle.net/4PCfE/Solution 3: Give your <select> boxes a class:<select id="one"class="installer-option"> ... CopyNow, you can use map() to extract the selected options into an array:var options = $('.select').map(function() { return $(this).val(); }); CopyYou can test to see if any default options have been chosen using inArray:if ($.inArray('default', options) != -1) { // There's a default option } CopyFrom there, you can join the strings together into your final URL:var file = options.join('_') + '.exe'; CopyDemo: http://jsfiddle.net/A2q47/3/Solution 4: var product_id=document.getElementById("one").value; var version_id=document.getElementById("two").value; var arch_id=document.getElementById("three").value; Copysomething like this should work http://jsfiddle.net/9a8YH/4/ Share Post a Comment for "Three Select Boxes Interacting To Yield One Result - Html, Javascript Or Jquery" Top Question How To Style A Programatically Add Element In Angular Could I please ask for help with the following (pictures ar… Mobx Observable Array Not Updated I am declaring a observable array in the following way in r… How To Specify Color Space For Canvas In JavaScript? What is the default color space used in JS canvas? How can … How Can I Force Download With Html And/or Javascript? So I have a this code: My Song How can I make it so t… Javascript Math Different To What I Thought It Should Be Just wondering if someone knows what is wrong with my javas… Rxjs - Consume API Output And Re-query When Cache Is Empty I'm trying to implement a version of this intro to RxJS… How Can I Remove Data Which Is Stored In Local Storage? If I console.log(localStorage.getItem('cartCache'))… How Can I Detect CSS Variable Support With JavaScript? The latest version of Firefox has support for CSS Variables… How To Replace Text With Jquery? Is it possible I can replace my name with 'anonymous… Trying To Make Navigation Bar For Tablet Site I'm designing a navigation bar for a tablet website. Th… December 2024 (1) November 2024 (38) October 2024 (65) September 2024 (22) August 2024 (220) July 2024 (194) June 2024 (444) May 2024 (702) April 2024 (443) March 2024 (883) February 2024 (912) January 2024 (833) December 2023 (897) November 2023 (392) October 2023 (554) September 2023 (306) August 2023 (334) July 2023 (276) June 2023 (399) May 2023 (229) April 2023 (126) March 2023 (149) February 2023 (174) January 2023 (288) December 2022 (130) November 2022 (223) October 2022 (173) September 2022 (172) August 2022 (494) July 2022 (309) June 2022 (324) Menu Halaman Statis Beranda © 2022 - JavaScript General