I'm having trouble with the following code I have written for a form im creating:
The first two lines specify me hiding a field from the user.
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.
After the function is written I want it to be called everytime StatusGroup is changed.
And the last line specifies that I want autoSet() called when the page is first loaded.
Any insight as to why the following is not working?
$(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();
});
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.
<label for="StatusGroup">
<span class="field">
span class="<#ERROR name="ERRORStatus">"><b>Status</b></span>
</span>
select id="StatusGroup" name="StatusGroup" size="1" class="f-name" tabindex="4">
<option selected><#PARAM name="StatusGroup"></option>
<option value="Distance Ed">Distance Ed</option>
<option value="Fac/Research">Fac/Research</option>
<option value="Graduate">Graduate</option>
<option value="Undergraduate">Undergraduate</option>
<option value="Staff">Staff</option>
</select><br />
</label>
Nevermind! Got it, thank you all :)
function() {autoSet(); }, it's simplyautoSet