Hello, folks -- I'm very new at this, so please pardon my ignorant
question.

I have a text field and a select input. My code sets the text field
when the select changes.

What I'd like to do is have it NOT do this when the page is first
loaded, but only when the user touches one of the select inputs. (This
is because I want to preserve whatever the user may have typed before
they reloaded the page with a submit, which can also change the
choices of the select input.)

Here's my code so far:

    $(document).ready(function() {
       $("select").change(function() {
            switch ($(this)[0].id)
            {
            case 'depotspec_list':
                        document.getElementById('depotspec').value = 
$(this)[0].value;
                        break;
            case 'labelone_list':
                        document.getElementById('labelone').value = 
$(this)[0].value;
                        break;
            case 'labeltwo_list':
                        document.getElementById('labeltwo').value = 
$(this)[0].value;
                        break;
            default:
                alert ($(this)[0].id);
            }
        }).change();
    });

My first thought was to just remove the "$(document).ready(function()
{});" wrapping. But that doesn't work.

I'm sure I'm just missing some fundamental bit here. Thanks in advance.

Reply via email to