I am currently working with jquery ui and ajax / post submit tabs without refreshing the page. With some recommendations, I managed to get the div #wmd-preview sent when I clicked the next button. The problem is that I also have other fields that I would like to send at the same time when the next button is clicked on different tabs.
How can I present the input values of various input fields on different tabs when I click the next button? EXAMPLE
(for some tests, I currently have other input fields with keyboard and timer settings)
JS-NEXT / Previous button combined with submit / ajax
<script> 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("<a href='#' class='next-tab mover' rel='" + next + "'>Next Page »</a>"); } if (i != 0) { prev = i; $(this).append("<a href='#' class='prev-tab mover' rel='" + prev + "'>« Prev Page</a>"); } }); $('.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; }); }); </script>
HTML
<div id="tab-1" class="ui-tabs-panel ui-tabs-hide"> <label for="title">Title</label> <input type="text" id="title" name="title" size="60" autocomplete="off" value="<? $title ?>"/> <div id="wmd-editor" class="wmd-panel"> <div id="wmd-button-bar"></div> <textarea id="wmd-input" name="wmd-input"></textarea> </div> <div id="wmd-preview" class="wmd-panel"></div> <div id="wmd_result"></div> <div id="title_input"style="padding:20px;"></div> </div> <div id="tab-2" class="ui-tabs-panel ui-tabs-hide"> <label for="name">Name</label> <input type="text" id="name" name="name" size="60" autocomplete="off" value="<? $name ?>"/> <div id="name_input"></div> </div>
Php
<? if (isset($_POST['title'])){ $wmdVal = $_POST['title']; echo ('<div id="title_input"><span id="resultval"><h2>Title Echo result:</h2>'.$wmdVal.'</span></div>'); } if (isset($_POST['wmdVal'])){ $wmdVal = $_POST['wmdVal']; echo ('<div id="wmd_result"><span id="resultval"><h2>Description Echo result:</h2>'.$wmdVal.'</span></div>'); } if (isset($_POST['name'])){ $name = $_POST['name']; echo ('<div id="name_input"><span id="resultval"><h2>Description Echo result:</h2>'.$name.'</span></div>'); } ?>
source share