Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can use this jQuery:</p> <p><kbd><a href="http://jsfiddle.net/8Tv9m/" rel="nofollow">jsFiddle here</a></kbd></p> <pre><code>$(document).ready(function() { $( "#Main" ).tabs(); $('[id^=ui-id-]').click(function() { var tabId = $(this).attr('id'); alert('Tab clicked: ' + tabId ); if (tabId == 'ui-id-1') { $('#LoginForm').submit(); }else if (tabId == 'ui-id-2') { $('#form2').submit(); }else if (tabId == 'ui-id-3') { $('#form3').submit(); } }); }); </code></pre> <p>jQueryUI tabs all have IDs beginning with <code>ui-id-#</code>, where # is the tab number (for example, <code>ui-id-3</code>.</p> <p>The selector <code>$('[id^=ui-id-]')</code> means: <em>For any element whose ID attribute begins with <code>ui-id-</code>, trap the click event and do this...</em></p> <p>Note that the <code>&lt;form&gt;</code> tag must have an ID attribute, as specified in the above code. For example, for the form on Tab 3:</p> <pre><code>&lt;form id="form3" action="whatever.php" method="POST"&gt; </code></pre> <hr> <p>Suppose each tab has a form on it and, for example, the forms all have IDs that are sequentially numbered according to the tab they are on, such as Form-1, Form-2, Form-5, etc. Then you could use the line <code>var tabId = $(this).attr('id')</code> to do this:</p> <pre><code>$(document).ready(function() { $( "#Main" ).tabs(); $('[id^=ui-id-]').click(function() { var tabId = $(this).attr('id'); //ui-id-4 var tabNum = tabId.split('-')[2]; //4 $('#Form-' + tabNum).submit(); }); }); </code></pre> <p>For example, suppose the tab's ID is <code>ui-id-4</code>, then you would want to give the <code>&lt;form&gt;</code> for tab 4 an ID: <code>&lt;form id="Form-4"&gt;</code>. The above code would then submit that form when the tab was clicked.</p> <hr> <p>Note that the above code expects that your form tags will have an ID, such as:</p> <pre><code>&lt;form id="myFormId" action="somepage.php" method="POST" &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