How to Convert "Different" Multiple

  • maybe i don't understand the question as your wrote it - so to clarify, you have two different functions that you need to fire, but only want one button to fire both functions... is that correct? – HolyMoly Mar 09 '17 at 03:39
  • Yes I will now edit the question so it is more clear. The functions are different yet similar. – SeekLoad Mar 09 '17 at 03:41
  • But NOT fire from one and the same button simultaneous. They need to fire one function from one button by the ` – SeekLoad Mar 09 '17 at 03:47
  • oh, I see. So then you need to get the value of the select - and fire whichever function corresponds to that selection. I will update my answer real quick. – HolyMoly Mar 09 '17 at 03:49
  • EXACTLY. That is the problem. I know I can not use "onclick" on an select option box with one button. Sow how do I solve that one? – SeekLoad Mar 09 '17 at 03:51
  • But thank you for telling me how to shorten the codes. I really wanted to do some clean up anyway, because the entire page has too much codes. Here I only cut out what I wanted help with. – SeekLoad Mar 09 '17 at 03:53
  • sorry, i was editing my answer and deleted some of the code accidentally! lol – HolyMoly Mar 09 '17 at 04:01
  • one last thought, if you are using a dropdown select - you can use an onchange event listener to fire a function ;) here is an old, but wordy example in an old answer i gave someone (scroll to the bottom of my answer, which if i wrote it now - would be a lot cleaner, lol) - the concept is what is important.... http://stackoverflow.com/questions/39008998/javascript-update-price-select-onchange/39009697#39009697 – HolyMoly Mar 09 '17 at 04:30
  • I thought of that too, but that is the problem since I can not put `onChange` in ` – SeekLoad Mar 09 '17 at 11:52
  • I did search and I took a look in your example before I posted this help question. The problem I was facing with your example is that it calls on the same function with different attributes. But in this case I have two separate functions that should be chosen by choice from the menu and fired from the button. – SeekLoad Mar 09 '17 at 11:53
  • As for changing your old answer, no problem. I did save on my laptop the old answer to ass maybe one day that could come in handy. I do want to make a clean up of my JS anyway so the old answer will come in handy for sure. – SeekLoad Mar 09 '17 at 11:54
  • How ever I will test this new answer you gave here. It is a bit different then the answer you gave on the other page and this might work. I will answer to you after I test it and tell you how it went. – SeekLoad Mar 09 '17 at 11:56
  • Your example has no fire button for the option. Also i tried it without it and with a submit button. No result it did not work. If there is no file I do get the alert "Please attach a file to upload". But when there is a file nothing happens. I added the selectValue this way `var selectValue = "TXTaSourceFiles";` did I do something wrong there? – SeekLoad Mar 09 '17 at 13:03
  • Also my select box looks like this `` – SeekLoad Mar 09 '17 at 13:04
  • ' var selectValue = "TXTaSourceFiles" ` is not correct. The select should have an id or something, and you need to grab it by it's id or it's name and then with JS get the value of it. Copying and pasting what I wrote will not work for you - because I do not have all of your relevant code to write it in a way that will run correctly. An example of how to grab the VALUE of the select is `var selectValue = document.getElementById("unlimited").value;` 1) you get the select by it's id or it's name 2) you extract the value from it and assign it to a variable. – HolyMoly Mar 09 '17 at 15:11
  • Now I used exactly `var selectValue = document.getElementById("unlimited").value;` and I even tried `var selectValue = document.getElementById("TXTaSourceFiles").value;` still nothing. Now it does not even show the alert anymore. – SeekLoad Mar 09 '17 at 19:40
  • The select looks like this now `` – SeekLoad Mar 09 '17 at 19:43