Skip to content

Instantly share code, notes, and snippets.

@AJFaraday
Created August 2, 2011 20:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AJFaraday/1121153 to your computer and use it in GitHub Desktop.
Save AJFaraday/1121153 to your computer and use it in GitHub Desktop.
jquery hiding/showing feild
# my jquery specifics (jq_actions.js)
var $j = jQuery.noConflict();
var $extra_kinds = 'of <input id="indicator_number_name" name="indicator[number_name]" size="15" type="text" />'
$j(document).ready(function(){
$j("#kinds").change(function(){
var $value = $j('#indicator_kind').val();
if ($value == "number")
{
$j('#extra').html($extra_kinds);
}
else
{
$j('#extra').html('');
}
});
});
# in my view
<td id='kinds'><%= f.select :kind, options_for_select(['number', 'time', 'achieved']), :id => "test" %><div id="extra" /></td>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment