Reputation: 1634
I am using a jQuery change event that is working fine apart from an addition I just made. What I am trying to do, is when a user selects anything other than 'NEW' from the select, then show an input element. I assumed that this would work with just an else statement, but I was wrong. I would be grateful if someone could check my code and show me where I am going wrong? Thanks
<!--- dropdown for new user addition -->
<script language="javascript" type="text/javascript">
$(function() {
$("#fld_company").show();
$("#data").hide();
$("#fld_company").live('click', function() {
$("#fld_fld").toggle(1000);
$("#formMessage").toggle(1000);
});
$("#AUSR_company").live('change', function() {
if($(this).val()=="new")
{
$("#data").slideDown(1000);
}
else
{
$("#AUSR_name").show().slideDown(1000);
}
});
});
</script>
<!--- end of dropdown for new user addition -->
<dl>
<dt>
<label for="AUSR_name" class="opt">Full Name:</label>
</dt>
<dd>
<input id="AUSR_name" name="AUSR_name" type="text" size="32" maxlength="128" value = "" />
</dd>
</dl>
Upvotes: 1
Views: 5628
Reputation: 5905
Based on your last comment, the below is what you need, but I have already seen that this is what you said wasn't working in the question. PLease explain in what way it wasn't working?
$("#AUSR_company").live('change', function(e) {
if($(this).val() =="new") {
$("#data").show();
} else {
e.stopPropagation();
$("#AUSR_name").show(3000)
}
});
Upvotes: 2
Reputation: 6071
Why don't you use .click()
and .change()
instead? You can read more about them here: http://api.jquery.com/category/events/
Upvotes: 1
Reputation: 222060
$("#AUSR_company").live('change', function() {
should be
$("#AUSR_name").live('change', function() {
Upvotes: 0