image video select

This commit is contained in:
Harry Bomrah 2016-02-23 14:42:32 +08:00
parent a338b55a4b
commit 9fba36489e
1 changed files with 6 additions and 15 deletions

View File

@ -26,7 +26,7 @@
<div class="controls"> <div class="controls">
<div><%= t("choose_type") %></div> <div><%= t("choose_type") %></div>
<%= <%=
select_tag "ad_image[exchange_item]", options_for_select(@item,@item_choose), prompt: t('select'),:onchange => "chg(this.options[this.options.selectedIndex].value)" select_tag "ad_image[exchange_item]", options_for_select(@item,@item_choose), prompt: t('select')
%> %>
</div> </div>
</div> </div>
@ -189,20 +189,11 @@
<%= f.submit t('submit'), class: 'btn btn-primary' %> <%= f.submit t('submit'), class: 'btn btn-primary' %>
</div> </div>
<script type="text/javascript"> <script type="text/javascript">
window.onload=chg(document.getElementById("ad_image_exchange_item").value); $("div#exchange_item_" + $("#ad_image_exchange_item").val()).show();
$("#ad_image_exchange_item").on("change",function(){
function chg(a) $("div[id*=exchange_item]").hide();
{ $("div#exchange_item_" + $(this).val()).show();
var i=0; })
for(i=1;i<=2;i++)
{
document.getElementById("exchange_item_"+i).style.display = "none";
}
<% if !@ad_image.new_record? %>
document.getElementById("exchange_item_"+<%= @ad_image.exchange_item %>).style.display = "";
<% end %>
}
function checkSelect() function checkSelect()
{ {
if(document.getElementById("ad_image_exchange_item").value == "") if(document.getElementById("ad_image_exchange_item").value == "")