Note that there are some explanatory texts on larger screens.

plurals
  1. POExecute on enter-key-press
    primarykey
    data
    text
    <p>I have this code</p> <pre><code>&lt;script&gt; function cA( url ) { document.myform.action = url; } &lt;/script&gt; &lt;input type="whatever" name="whatever" id="whatever" /&gt; &lt;button class="whatever-button" id="defaultAction" value="Go for it" name="whatever" type="submit" onClick="cA('whatever.php#anchor')" &gt;Go for it &lt;/button&gt; </code></pre> <p>When you click the Go for it-Button, <code>whatever.php#anchor</code> is being loaded. How do I need to change the input tag's elements for it to execute the same <code>cA('whatever.php#anchor')</code> as the button click?</p> <p>So when a user presses enter in the field, the site <code>whatever.php#anchor</code> should be loaded or more specifically, <code>cA('whatever.php#anchor')</code> be executed.</p> <p>The page has more buttons, so making one button the default button does not work.</p> <p>PS:</p> <p>Wrapping all in one form does not work as the page's structure is</p> <pre><code>&lt;form&gt; &lt;script&gt; function cA( url ) { document.myform.action = url; } &lt;/script&gt; &lt;input type="whatever1" name="whatever1" id="whatever1" /&gt; &lt;button class="whatever1-button" id="defaultAction1" value="Go for it" name="whatever1" type="submit" onClick="cA('whatever.php#anchor1')" &gt;Go for it &lt;/button&gt; &lt;input type="whatever2" name="whatever2" id="whatever2" /&gt; &lt;button class="whatever2-button2" id="defaultAction2" value="Go for it" name="whatever2" type="submit" onClick="cA('whatever.php#anchor2')" &gt;Go for it &lt;/button&gt; &lt;input type="whatever3" name="whatever3" id="whatever3" /&gt; &lt;button class="whatever3-button" id="defaultAction3" value="Go for it" name="whatever3" type="submit" onClick="cA('whatever.php#anchor3')" &gt;Go for it &lt;/button&gt; ... &lt;/form&gt; </code></pre>
    singulars
    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.
 

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