2016-08-23 5 views
0

私はrails 2.3.10からrails 4に移行しており、携帯電話で患者のスケジュールにメッセージを送信するアプリを持っています。私のアプリはスケジュールの患者のリストを表示し、1つ以上を選択してメッセージを送信するとcheck_box_tagが各行に存在します。 私は部分を呼び出すフォームを持っており、この部分はcheck_box_tagのリストを含んでいます。選択された各チェックボックスは、javascript変数selected_idsに格納され、メインフォームのtext_field_tagに戻ります。問題は、パラメータselected_ids LINK_TO空になるイベントであるが、私は、フォームの一部の下にはcheck_box_tag 上で見ることができ、部分的およびJavaScript:Rails 4はjavascriptを含むtext_field_tagから値を取得するvar

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

は最後に働きました! onclickの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"%>

はあなたに人々をありがとう!

関連する問題