Javascript pop window from form how to update field back to main form

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 ?

Jesus bernardo Ruiz flores wrote:

<%=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}’);
")%>

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();
}

I am trying to implement your solution, but I don’t see any updates.

Here’s my code:

<%= link_to_function(“function_link”, "set_value(‘div_area_form’,
‘#{@item_codes}’); ") %>

The view source of the javascript shows this:

function_link

Any ideas?

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:

<% form_tag person_find_show_select_path, :method=>"get" do%> <%end%> <% switch=false for person in @persons %> <% switch=!switch %>"> <% end %>
Buscar Usuario: <%=select_tag "busqueda","Nombre CompletoRazon SocialId ServicioId ClienteContrato"%> <%=hidden_field_tag :id, "13"%> <%=text_field_tag :search, params[:search]%> <%=submit_tag "Buscar", :name=>nil%>
Nombre ID Cliente
<%=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}'); ")%> <%=person.id_cliente%>

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