I am currently working with Jquery UI tabs and dynamic select boxes. I am currently trying have the buttons disabled until user selects and item from the select box . Is it possible/How can get the user to first click on an item in the select box before advancing to the next tab? I dont have anything that I can build from but here is my EXAMPLE so far.
JS- For previous/next button
<script>
$(function() {
var $tabs = $('#tabs').tabs();
$(".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() {
$tabs.tabs('select', $(this).attr("rel"));
return false;
});
});
</script>
PHP/HTML
<select name="gender" id="gender" class="update" size="7">
<option value="">Select one</option>
<?php if (!empty($list)) { ?>
<?php foreach($list as $row) { ?>
<option value="<?php echo $row['id']; ?>">
<?php echo $row['category_name']; ?>
</option>
<?php } ?>
<?php } ?>
</select>
<select name="category" id="category" class="update" disabled="disabled" hidden="hidden" size="7">
<option value="">----</option>
</select>
<select name="colour" id="colour" class="update" disabled="disabled" hidden="hidden" size="7">
<option value="">----</option>
</select>
There are some solutions (with the 2nd solution you can nevertheless change the tab without clicking the next button).
1.) You can disable the second tab (
$('#tabs').tab({ disabled: [1] });) and enable the tab, if an option is selected e.g. by adding following change handler:Also see this example.
2.) You can update your next click handler; change the tab only if a gender is choosen:
Also see this example.
3.) Add a tab select handler, which returns
false, if the user is on the first tab and no gender is choosen; add an object as tab parameter with a tab select handler:Also see this example.
Finally I prefer the first solution because the user can see that the second tab can’t be reached (until he choose a gender) and the result of choosing (enabling the tab) will be shown immediately.
=== UPDATE ===
Ok, if you have different numbers of selects (deppending on the values of the previous selects), here an alternative (untested) solution:
1.) Replace the content of the
jQuery.getJSONin the updateSelectBox.js (the really last select will be marked):2.) Call the tab with disabled tab 2
3.) Add following select change handler: