Show:Hide a textfield after changing in dropdown list
I can't figure out why it dosen't work. I'd like to show/hide a <p> block depending on the value selected in the dropdown list:
-
$(document).ready(function(){
$('#report_rep_type').change(function(){
$('#report_rep_type').change(function(){
if($(this).text()!= 'Contigency Liabilities/Others')
$('#someElement').hide();
else
$('#someElement').show();
});
});
});
HTML code:
-
<form action="my action>
<fieldset>
<legend>Report details</legend>
<p>
<label for="report_rep_type">Report type</label><br />
<select id="report_rep_type" name="report[rep_type]"><option value="">Please select</option>
<option value="Scientific & Technical">Scientific & Technical</option>
<option value="Financial">Financial</option>
<option value="Contigency Liabilities/Others">Contigency Liabilities/Others</option></select>
</p>
<p id="rpt_object">
<label for="report_object">Object</label><br />
<input id="report_object" name="report[object]" size="30" type="text" />
</p>
<p>
<label for="report_frequency">Frequency</label><br />
<select id="report_frequency" name="report[frequency]"><option value="">Please select</option>
<option value="3">quarterly</option>
<option value="6">half-yearly</option>
<option value="12">annually</option>
<option value="24">biannually</option></select>
</p>
<p>
<label for="report_interval">Interval, weeks</label><br />
<input id="report_interval" name="report[interval]" size="30" type="text" />
</p>
<p>
<label for="report_alert1_interval">Alert 1 interval, weeks</label><br />
<input id="report_alert1_interval" name="report[alert1_interval]" size="30" type="text" />
</p>
<p>
<label for="report_alert2_interval">Alert 2 interval, weeks</label><br />
<input id="report_alert2_interval" name="report[alert2_interval]" size="30" type="text" />
</p>
<p>
<label for="report_formatted_end_date">Report end date</label><br />
<input id="report_formatted_end_date" name="report[formatted_end_date]" size="10" type="text" />
</p>
</fieldset>
</p>
<p>
<button class="button " type="submit"><img alt="Tick" src="/images/silk/icons/tick.png?1245400388" /> Create</button>
</p>
</form>
Any idea ? THank you