Wednesday 15 September 2010

javascript - How to show hide a text field when something is selected from a drop down. -


My question is, if I select something in my drop down like ABS when ABS is selected I will show a text box How can I do the work that I am not doing for additional information for input ... any help is appreciated!

This is my app.js

  $ (document) .ready (function () {$ ('# Indirect_id') .changes (function () {var indirect_id = $ (This) .val (); if (indirect_id == 'ABS') {$ ('# sick_comment') Show ();} Else {$ ('# sick_comment'). Hide ();}}) ;  

This is my view

  .row-fluid = simple_form_for @ entry, url = & gt; url_ ((admin = & gt; 'entry ',: Action => make' ')) :: method =>: post | f |% table.table.table-bordered.table-striped {: style => table-layout : Fixed; width: 100%! Important; '}% th.lt indirect code:% td.lt = f.input_field: indirect_id ,: as = & gt; Select, {= value = & gt; '}}% s <: label = & gt; wrong, archive = & gt; [' PD ',' VAC ',' ABS '] ,: id = & gt; Indirect_ID ',: input_hotel = & gt; .lt optional comment% td.lt = f.text_field: sick_day ,: label = & gt; wrong, id = & gt; sick_comment': input_html = & gt; Value = & gt; ''}% table.table table-bordered.t enabled-stripe {: style = & gt; 'Table layout: fixed; Width: 100%! Important; '} = F.button: submit, "submit",: class => 'BTN BTN-Primary' ,: style = & gt; 'Margin-left: 50px;'  

If this is the full text of your app.js, then you have an end bracket and Brackets:

  $ (document) .ready (function () {$ ('# indirect_id'). Change (function () {var indirect_id = $ (this) .val (); If (Indirect_id == 'ABS') {$ ('# sick_comment') Show ();} and {$ ('# sick_comment'). Hide ();}});});  

No comments:

Post a Comment