Note that there are some explanatory texts on larger screens.

plurals
  1. POAjax submit various input values with jquery UI next button click
    primarykey
    data
    text
    <p>I am currently working with jquery ui tabs and ajax/post submit without page refresh. With some guidance I have been able to get the div <code>#wmd-preview</code> submited when clicking the next button. The issue is that I also have other fields I will like to submit at the same time when the next button is clicked in various tabs. </p> <p>How can I submit the input values of various input fields in different tabs when clicking the next button? <a href="http://webprolearner.ueuo.com/dropdown-menu/test1.php" rel="noreferrer">EXAMPLE</a></p> <p><em>(for some testing i currently have the other input fields submit with keyup and timer setup)</em></p> <p>JS- NEXT/Previous button merged with submit/ajax</p> <pre><code>&lt;script&gt; var currentTab = 0; $(function() { var $tabs = $('#tabs').tabs({ disabled: [0, 1, 2] , select: function() { if (currentTab == 0) { $.ajax({ type: "POST", url: "test1.php", data: { "wmdVal": $("#wmd-preview").html() }, success: function(result) { $('#wmd_result').html( $('#resultval', result).html()); } }); } } , show: function(event, ui) { currentTab = ui.index; } }); $(".ui-tabs-panel").each(function(i) { var totalSize = $(".ui-tabs-panel").size() - 1; if (i != totalSize) { next = i + 2; $(this).append("&lt;a href='#' class='next-tab mover' rel='" + next + "'&gt;Next Page &amp;#187;&lt;/a&gt;"); } if (i != 0) { prev = i; $(this).append("&lt;a href='#' class='prev-tab mover' rel='" + prev + "'&gt;&amp;#171; Prev Page&lt;/a&gt;"); } }); $('.next-tab, .prev-tab').click(function() { var tabIndex = $(this).attr("rel"); $tabs.tabs('enable', tabIndex) .tabs('select', tabIndex) .tabs("option","disabled", [0, 1]); return false; }); }); &lt;/script&gt; </code></pre> <p><strong>HTML</strong></p> <pre><code>&lt;div id="tab-1" class="ui-tabs-panel ui-tabs-hide"&gt; &lt;label for="title"&gt;Title&lt;/label&gt; &lt;input type="text" id="title" name="title" size="60" autocomplete="off" value="&lt;? $title ?&gt;"/&gt; &lt;div id="wmd-editor" class="wmd-panel"&gt; &lt;div id="wmd-button-bar"&gt;&lt;/div&gt; &lt;textarea id="wmd-input" name="wmd-input"&gt;&lt;/textarea&gt; &lt;/div&gt; &lt;div id="wmd-preview" class="wmd-panel"&gt;&lt;/div&gt; &lt;div id="wmd_result"&gt;&lt;/div&gt; &lt;div id="title_input"style="padding:20px;"&gt;&lt;/div&gt; &lt;/div&gt; &lt;div id="tab-2" class="ui-tabs-panel ui-tabs-hide"&gt; &lt;label for="name"&gt;Name&lt;/label&gt; &lt;input type="text" id="name" name="name" size="60" autocomplete="off" value="&lt;? $name ?&gt;"/&gt; &lt;div id="name_input"&gt;&lt;/div&gt; &lt;/div&gt; </code></pre> <p><strong>PHP</strong></p> <pre><code> &lt;? if (isset($_POST['title'])){ $wmdVal = $_POST['title']; echo ('&lt;div id="title_input"&gt;&lt;span id="resultval"&gt;&lt;h2&gt;Title Echo result:&lt;/h2&gt;'.$wmdVal.'&lt;/span&gt;&lt;/div&gt;'); } if (isset($_POST['wmdVal'])){ $wmdVal = $_POST['wmdVal']; echo ('&lt;div id="wmd_result"&gt;&lt;span id="resultval"&gt;&lt;h2&gt;Description Echo result:&lt;/h2&gt;'.$wmdVal.'&lt;/span&gt;&lt;/div&gt;'); } if (isset($_POST['name'])){ $name = $_POST['name']; echo ('&lt;div id="name_input"&gt;&lt;span id="resultval"&gt;&lt;h2&gt;Description Echo result:&lt;/h2&gt;'.$name.'&lt;/span&gt;&lt;/div&gt;'); } ?&gt; </code></pre>
    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.
 

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