Open the correct URL based on radio button and button selection |
Open the correct URL based on radio button and button selection |
Scrabble |
Jan 18 2023, 05:14 PM
Post
#1
|
Group: Members Posts: 4 Joined: 18-January 23 Member No.: 28,755 |
I have spent days on this and can not figure out how to get the correct stock symbol to open the correct radio button chosen. I am very limited on my knowledge of javascript.
This is what I have started. It is not working properly. If 'StockTwits' (the first radio button) is selected, then any button I press always opens Arista Networks (the first button). If 'Yahoo' (the second radio button) is selected, then any button I press always opens Applied DNA Sciences (the second button). If 'SEC Filings' (the third radio button) is selected, then any button I press always opens Avaya (the third button). And so on. Then I 'corrected' the line in my code from: if(SiteChoiceNames[y].checked) to: if(TickerLookupNames[y].checked) Now it does nothing. I haven't even gotten to the ones with more URL after the ticker symbol, much less the OPTIONS one having the ticker in the URL twice, for example where: If the DIVIDENDS radio button is selected then it will open: https://www.nasdaq.com/market-activity/stoc...ividend-history If the OPTIONS radio button is selected then it will open: https://finance.yahoo.com/quote/APDN/options?p=APDN <html> <head> </head> <body> <center> <input type="checkbox" id="neworsame" onClick="setLinkTarget(this, '#my-link')" checked><label for="neworsame">Open in new</label> tab <input type="radio" name="SiteChoice" id="1StockTwits" value="https://stocktwits.com/symbol/" checked><label for="1StockTwits">StockTwits</label> <input type="radio" name="SiteChoice" id="2Yahoo" value="https://finance.yahoo.com/quote/"><label for="2Yahoo">Yahoo</label> <input type="radio" name="SiteChoice" id="3SECFilings" value="https://fintel.io/sfs/us/"><label for="3SECFilings">SEC Filings</label> <input type="radio" name="SiteChoice" id="4Offerings" value=""><label for="4Offerings">Offerings</label> <input type="radio" name="SiteChoice" id="5Dividends" value=""><label for="5Dividends">Dividends</label> <input type="radio" name="SiteChoice" id="6Splits" value="https://www.stocksplithistory.com/?symbol="><label for="6Splits">Splits</label> <input type="radio" name="SiteChoice" id="7Options" value=""><label for="7Options">Options</label> <input type="radio" name="SiteChoice" id="8ShortInterest" value="https://shortsqueeze.com//shortinterest/stock/term2.php?s="><label for="8ShortInterest">Short Interest</label> <input type="radio" name="SiteChoice" id="9Float" value=""><label for="9Float">Float</label> <input type="radio" name="SiteChoice" id="10Ownership" value=""><label for="10Ownership">Ownership</label> <input type="radio" name="SiteChoice" id="11Historical" value=""><label for="11Historical">Historical</label> <input type="radio" name="SiteChoice" id="12Earnings" value=""><label for="12Earnings">Earnings</label> <input type="radio" name="SiteChoice" id="13Titan" value="https://www.stocktitan.net/news/"><label for="13Titan">Stock Titan</label> </center> <br> <button onclick="opentabs()" name="TickerLookup" value="ANET">Arista Networks</button> <button onclick="opentabs()" name="TickerLookup" value="APDN">Applied DNA Sciences</button> <button onclick="opentabs()" name="TickerLookup" value="AVYA">Avaya</button> <button onclick="opentabs()" name="TickerLookup" value="BJ">BJ's Wholesale Club</button> <button onclick="opentabs()" name="TickerLookup" value="KO">Coca-Cola</button> <button onclick="opentabs()" name="TickerLookup" value="LMT">Lockheed Martin</button> <button onclick="opentabs()" name="TickerLookup" value="MNKD">Mannkind Corporation</button> <button onclick="opentabs()" name="TickerLookup" value="NEE">NextEra Energy</button> <button onclick="opentabs()" name="TickerLookup" value="TGTX">TG Therapeutics</button> <button onclick="opentabs()" name="TickerLookup" value="XRX">Xerox</button> <script> function opentabs() { var SiteChoiceNames = document.getElementsByName('SiteChoice'); var TickerLookupNames = document.getElementsByName('TickerLookup'); for(var x = 0; x < SiteChoiceNames.length; x++) { if(SiteChoiceNames[x].checked) { for(var y = 0; y < TickerLookupNames.length; y++) { if(TickerLookupNames[y].checked) { window.open(SiteChoiceNames[x].value + TickerLookupNames[y].value); } } } } } </script> </body> </html> This post has been edited by Scrabble: Jan 18 2023, 05:55 PM |
Lo-Fi Version | Time is now: 25th September 2024 - 09:29 PM |