Guest User

Untitled

a guest
May 25th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. ## javascript in application.js
  2.  
  3. //for stencil_controller
  4. function show_category_override() {
  5. value = document.findElementById('stencil_category').value;
  6. if value == "NEW CATEGORY -->" {
  7. document.getElementById('override').display='';
  8. } else {
  9. document.getElementById('override').display='none';
  10. }
  11. }
  12.  
  13. ## controller
  14.  
  15. def new
  16. @stencil = Stencil.new
  17. @categories = Stencil.categories #array of text
  18. @categories << "NEW CATEGORY -->"
  19. end
  20.  
  21. ## view
  22.  
  23. <p class="content_head">
  24. Create New Stencil
  25. </p>
  26.  
  27. <% form_for :stencil, :url => {:action => "create"}, :html => {:multipart => true} do |f| -%>
  28.  
  29.  
  30. <p class="content">
  31. <%= f.label :image, 'stencil image' -%><br/>
  32. <%= f.file_field :image, :size => 40 -%>
  33. </p>
  34.  
  35. <p class="content">
  36. <%= f.label :title, 'title' -%><br/>
  37. <%= f.text_field :title, :size => 40 -%>
  38. </p>
  39.  
  40. <p class="content">
  41. <%= f.label :category, 'category' -%><br/>
  42. <%= f.select :category, @categories, {:selected => "Other"}, {:onchange => "show_category_override();"} -%>
  43. <span id="override" style="display:none;"><%= text_field_tag :category_override, nil, :size => 20 -%></span>
  44. </p>
  45.  
  46. <p class="content">
  47. <%= submit_tag "Create Stencil" -%>
  48. </p>
  49.  
  50.  
  51. <% end -%>
Add Comment
Please, Sign In to add comment