The initial idea, is to hide an input element and show it based on a change event in a select element. However, the code I have is not hiding the input and so nothing happens with the change statement. Could someone check the code and show me my error. Thanks
<label for="AUSR_companyname">Company Name:</label>
<input id="AUSR_companyname" name="AUSR_companyname" type="text" class="text ui-widget-content ui-corner-all inputbox AUSR_companyname" value = "" />
!--- dropdown for new user addition -->
<script language="javascript" type="text/javascript">
$("#AUSR_companyname").hide();
$(function() {
jQuery("#AUSR_company").live('change', function() {
if($(this).val()=="new")
{
$("#AUSR_companyname").show();
}
});
});
</script>
<!--- end of dropdown for new user addition -->
++++UPDATE++++
This script is now causing error ‘missing ) after argument list’. Where have I missed it? Thanks
$(function() {
$("#AUSR_companyname, label[for=AUSR_companyname]").hide();
jQuery('#AUSR_company").live('change', function() {
if($(this).val()=="new")
{
$("#AUSR_companyname").show();
}
});
});
It looks like you are using jQuery. Take care that you have included the jQuery-files in the html header section.
After that, wrap your javascript code into the jQuery ready function:
EDIT: to answer your question you posted in your comment block:
To hide the label, too you could use something like this: