KTU wrote:
Hi
I have question where I run web form. Now on this form I have one field with link select user.
This link will pop up new window with javascript and on this window I have form with items which end user can select. Once selection is done end user press button Select User.
Now I need to close that javascipt window and send back value of that selection back to form and to the field which has textbox for that value.
Is this possible ?
Hi this i what I did, to select and user from one form and update a select box in another form:
This is the code for the view that show all the users found:
<table>
<tr> <% form_tag person_find_show_select_path, :method=>"get" do%> <td>Buscar Usuario:</td> <td><%=select_tag "busqueda","<option value='1' selected='true'>Nombre Completo</option><option value='2'>Razon Social</option
<option value='3'>Id Servicio</option><option value='4'>Id Cliente</option><option value='5'>Contrato</option>"%>
<%=hidden_field_tag :id, "13"%> <td><%=text_field_tag :search, params[:search]%></td> <td><%=submit_tag "Buscar", :name=>nil%></td> <%end%> </tr> <tr> <th colspan="3">Nombre</th> <th>ID Cliente</th> </tr> <% switch=false for person in @persons %> <tr class="<%= if switch "TRPAR" else "TRIMPAR" end %> <% switch=!switch %>"> <td colspan="3"><%=link_to_function("#{person.apellido} #{person.nombre}", "set_value('voip_person_id','#{person.id}'); set_value('voip_id_servicio','#{person.id_cliente}'); set_value('voip_contrato','#{person.id_cliente}'); set_value('voip_contacts_attributes__nombre','#{person.nombre.capitalize}'); set_value('voip_contacts_attributes__apellido','#{person.apellido.capitalize}'); set_value('voip_contacts_attributes__razon_social','#{person.razon_social}'); ")%></td> <td><%=person.id_cliente%></td> </tr> <% end %> </table>
And this is the function set_value inside public/javascripts/application.js
function set_value(id,value) { opener.document.getElementById(id).value=value; window.close(); }
Hope this help