problem creating function with javascript
<p>I'm having trouble with the following code I have written for a form im creating: </p>

<p>The first two lines specify me hiding a field from the user.  </p>

<p>The next thing I try to do is create a function that will set fields to a specific value if the StatusGroup field is set to Distance ed.</p>

<p>After the function is written I want it to be called everytime StatusGroup is changed.</p>

<p>And the last line specifies that I want autoSet() called when the page is first loaded.</p>

<p>Any insight as to why the following is not working?</p>

<pre><code>    $(document).ready(function() {
        $('#deliveryinput').css("position", "absolute");
        $('#deliveryinput').css("left", "-9999999");

        var autoSet = function() {
    if($('#StatusGroup').val() == 'Distance Ed') {
        $('#DeliveryGroup').val( 'mail' );
        $('#NVTGC').val('DIST'); }
    else if($('#StatusGroup').val() != 'Distance Ed'){
            $('#DeliveryGroup').val( 'pickup' );}
}


        $('#StatusGroup').change(function() {
            autoSet();
        });

        autoSet();


    });
</code></pre>

<p>I think you guys nailed the javascript, but I whenever I change StatusGroup the corresponding fields dont respond. Am I using the correct form identifiers? Im comparing the SelectId to its value Distance Ed. And same goes for DeliveryGroup and NVTGC.</p>

<pre><code>&lt;label for="StatusGroup"&gt;
&lt;span class="field"&gt;
span class="&lt;#ERROR name="ERRORStatus"&gt;"&gt;&lt;b&gt;Status&lt;/b&gt;&lt;/span&gt;
&lt;/span&gt;
select id="StatusGroup" name="StatusGroup" size="1" class="f-name" tabindex="4"&gt;
&lt;option selected&gt;&lt;#PARAM name="StatusGroup"&gt;&lt;/option&gt;
&lt;option value="Distance Ed"&gt;Distance Ed&lt;/option&gt;
&lt;option value="Fac/Research"&gt;Fac/Research&lt;/option&gt;
&lt;option value="Graduate"&gt;Graduate&lt;/option&gt;
&lt;option value="Undergraduate"&gt;Undergraduate&lt;/option&gt;
&lt;option value="Staff"&gt;Staff&lt;/option&gt;
&lt;/select&gt;&lt;br /&gt;
&lt;/label&gt;
</code></pre>

<p>Nevermind! Got it, thank you all :)</p>
