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><%= 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>
@ -189,20 +189,11 @@
<%= f.submit t('submit'), class: 'btn btn-primary' %>
</div>
<script type="text/javascript">
window.onload=chg(document.getElementById("ad_image_exchange_item").value);
function chg(a)
{
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 %>
}
$("div#exchange_item_" + $("#ad_image_exchange_item").val()).show();
$("#ad_image_exchange_item").on("change",function(){
$("div[id*=exchange_item]").hide();
$("div#exchange_item_" + $(this).val()).show();
})
function checkSelect()
{
if(document.getElementById("ad_image_exchange_item").value == "")