2016-08-23 2 views
0

레일 2.3.10에서 레일 4로 마이 그 레이션 중이며 핸드폰에 환자 스케줄로 메시지를 보낼 수있는 앱이 있습니다. 내 응용 프로그램은 일정의 환자 목록을 보여 주며 하나 이상의 메시지를 선택하고 각 행에 대해 check_box_tag가 존재합니다. 그래서 부분을 호출하는 양식이 있고이 부분에는 check_box_tag가있는 목록이 들어 있습니다. 선택된 각 확인란은 자바 스크립트 변수 selected_ids의 저장소이며 기본 폼의 text_field_tag로 돌아갑니다. 문제는 매개 변수 selected_ids LINK_TO 비어있는 이벤트입니다,하지만 난 형태의 부분 아래에는 check_box_tag 에 볼 수있는 부분과 자바 스크립트 :레일 4는 javascript를 포함하는 text_field_tag에서 값을 얻습니다.

function MultiSelectIDs(FieldName) { 
 
    var selected_ids = new Array() 
 
    var objCheckBoxes = document.getElementsByName(FieldName); 
 
    for(var i = 0; i < objCheckBoxes.length; i++){ 
 
    if (objCheckBoxes[i].checked) { 
 
     var x = selected_ids.splice(selected_ids.length,0, objCheckBoxes[i].id); 
 
    } 
 
    } 
 
    document.getElementById('selected_ids').value = selected_ids.join(", ") 
 
};
<% if [email protected]? && [email protected]? %> 
 
    <% for tagendamento in @tagendamento do %> 
 
    <tr> 
 
    <%= check_box_tag "#{tagendamento.id}", 0, false, :name=> "chk_agendamento", :onclick => "MultiSelectIDs('chk_agendamento')" %> 
 
<% end %> 
 
    
 
<%= text_field_tag :selected_ids %> 
 
<%= link_to 'Pré-Visualizar SMS',send_sms_queries_path(:sel_ids=>params[:selected_ids],:perfil=>params[:perfil], :visualizar => '1', :dt_envio=>(params[:dt_envio].nil?)? (Date.today - 3) : params[:dt_envio],:t_envio=>params[:t_envio],:tipo_msg=>params[:tipo_msg],:mensagem=>(!params[:mensagem].nil? and !params[:mensagem].blank?)? params[:mensagem] : @standard,:selec_tipotemplate_sms=>params[:selec_tipotemplate_sms],:date_agend_hc=>params[:date_agend_hc]), :target=>'_blank', :style => \t "color:black"%>

<%= text_field_tag :selected_ids %> 
    <%= link_to 'Pré-Visualizar SMS', send_sms_queries_path(:sel_ids  => params[:selected_ids], 
                  :perfil   => params[:perfil], 
                  :visualizar  => '1', 
                  :dt_envio  => (params[:dt_envio].nil?)? (Date.today - 3) : params[:dt_envio], 
                  :t_envio  => params[:t_envio], 
                  :tipo_msg  => params[:tipo_msg], 
                  :mensagem  => (!params[:mensagem].nil? and !params[:mensagem].blank?)? params[:mensagem] : @standard, 
                  :selec_tipotemplate_sms => params[:selec_tipotemplate_sms], 
                  :date_agend_hc => params[:date_agend_hc]), 
            :target => '_blank', 
            :style => "color:black"%> 

답변

0

마지막으로 일했다! 온 클릭 LINK_TO에서 text_field_tag의 추가 된 내용은 다음과 같습니다 :

<%= link_to 'Pré-Visualizar SMS', send_sms_queries_path(:selected_ids \t =>params[:selected_ids]), 
 
:target \t => \t '_blank', 
 
:style \t => \t "color:black", 
 
:onclick => "this.href = this.href + '&selected_ids=' + selected_ids.value"%>

당신에게 사람을 감사합니다!

관련 문제