5
The parent window (jsp) has a button to open the popup (child).
<input type="button" onclick="test();" value="Call Child Window" />
When you open the popup, there are text fields for the person to type a word.
Those input
are created dynamically, with a button and a function to create more input
. The values typed in input
are stored in an array and the qtdeCampos
is the amount of fields.
The function of buttons:
<script type="text/javascript">
var qtdeCampos = 0;
function addCampos() {
var objPai = document.getElementById("campoPai");
var objFilho = document.createElement("div");//Criando o elemento DIV;
objFilho.setAttribute("id","filho"+qtdeCampos);//Definindo atributos ao objFilho
objPai.appendChild(objFilho);//Inserindo o elemento no pai
//Escrevendo algo no filho recém-criado:
document.getElementById("filho"+qtdeCampos).innerHTML = "<input type='text' id='ctxt"+qtdeCampos+"' name='campo[]'>\n\<input type='button' onclick='removerCampo("+qtdeCampos+")' value='Apagar campo'>";
qtdeCampos++;
}
</script>
I would like to know how to pass this array of words typed in the popup to the parent page. The parent page will receive you in an array.
Do you really need to open a new window? Wouldn’t it be better with a dialog?
– Sergio
@Sergio believe so, because it can be several word insertions! There is a function in the popup that allowed to open several text fields.
– Pacíficão
In the popup there is a text input that the client will type something. You want to take this value and send it to the jsp that called it. Where exactly do you want to ship to? To a div q exists in the parent jsp? To another input?
– Matheus
@Matheus for a div that exists in the parent JSP.
– Pacíficão
@Peace One more thing, send when the user is typing or when the user exits the input or when the user clicks a "send"?
– Matheus
@Matheus by clicking send button.
– Pacíficão
@Peace, all the answers already answer your question
Como passar dados do popup para a página pai
, What you need now is to understand the answers. In all the answers the value of the popup was saved somewhere on the parent page, now what you need is to know how to manipulate this value on the parent page, think you need another question or just look closer at the answers that have already been given to you.– Pedro Camara Junior