tags:

views:

54

answers:

1

I have a process in place which detects if a select box is changed, if it does get changed, the content in a div reloads.

I've realised that when the form is submitted and has errors, the select box should have the option selected prior to submit, selected. If this is the case, the div needs to reload with the correct content.

My current method for detecting a change and reloading content based on id's is as follow:

//On drop-down change
$("#tiers").change(function() {
    var selectedId = $(this).val();
    if(selectedId != 0) {
        container = new Array();
        var container = $('#tier'+selectedId+' a.removePanel').map(function() { 
            var match = this.id.match(/\d+$/);
            return match ? match[0] : null;
        }).get();
        loadContent(container);
    } else {
        $('#panels').html('<p class="error">Please select a Tier from the drop-down in order to assign Panels.</p>');
    }
});

EDIT#1

Managed to do this using PHP and Smarty by simply detecting if the $_post variable had content.

A: 

I did this many times before, after your postback just post an array of all the id's of the checkboxes that are selected, and then set the checkboxes with the ID's in the array to selected .

Nealv
I'm not working with checkboxes, I'm working with a select box.