Note that there are some explanatory texts on larger screens.

plurals
  1. POOpen page in new tab using javascript window.open(elementName.elementValue) in anchor tag
    primarykey
    data
    text
    <p>I've examined tons of examples over the past couple days, but still can't find an answer to my dilemma. In order for me to explain my dilemma first I'll show you an example of something I have that works, then explain how I would rather it work (but can't seem to achieve).</p> <p>This works:</p> <pre><code>&lt;form&gt; &lt;select name="url"&gt; &lt;option selected="selected" value=""&gt; Choose Donation Amount &lt;/option&gt; &lt;option value="http://www.url1.com"&gt;URL#1&lt;/option&gt; &lt;option value="http://www.url2.com"&gt;URL#2&lt;/option&gt; &lt;option value="http://www.url3.com"&gt;URL#3&lt;/option&gt; &lt;option value="http://www.url4.com"&gt;URL#4&lt;/option&gt; &lt;option value="http://www.url5.com"&gt;URL#5&lt;/option&gt; &lt;option value="http://www.url6.com"&gt;URL#6&lt;/option&gt; &lt;/select&gt; &lt;input type="submit" value="Submit" onclick="if (url.value) window.open(url.value);" /&gt; &lt;/form&gt; </code></pre> <p>But what I'd rather do is capture the option and open the URL using an anchor tag (rather than input[type"submit"]), something like this (to replace the input tag before the closing form tag):</p> <pre><code>&lt;a href="javascript:void(if (url.value) window.open(url.value));" target="_blank"&gt;Submit&lt;/a&gt; </code></pre> <p>The above line doesn't work, and I can't figure out how to form it correctly. Help?</p> <p>I know this doesn't seem logical, especially since I already have it working using a submit button, but it's also not practical for me to explain exactly why I don't want to use input or button type="submit", , or PHP. Please, it really needs to be inline javascript in an anchor tag. Thanks.s :-)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload