2
We have a search screen that works like this: There is a main screen. On it a button calls the search screen. This screen is loaded into a IFrame
that is inside a Modal jquery-ui(Dialog)
. On this screen (search) I select some filters and when clicking on the search button, I open a grid with the search result. Well, when I select a CPF or No. Chart, for example, it closes the screen and on the original calling page, the Textbox
are then filled with these values. What’s going on. This search screen, previously developed within ShowModalDialog
. For this reason, it works only on IE(Modo Modal)
. In the Chrome
it goes up normally, but not in a Modal way, which is why the company wants it to be validated in Chrome as well, but retaining the functionality that’s in IE today. So we set out for a solution jquery
, for now to meet this specification, but the problem is this. Even clicking does not give any error, but nothing happens. The survey does not complete. Someone told me to switch to the ajax
and see how it works, but I wonder if with the Dialog
of jquery
can do.
See the screen below. When clicking on a contract, the Modal should be closed and in the background screen, the Contract field should be filled in and the field beside (ready only) should be filled in with the Name.
When clicking on the contract or name, anyone who has a "link" is called a javascript() function and it is she who closes the Dialog and populates the bottom screen (calling page). See the function below:
function selecionar(num_contrato, cod_ts_contrato, nome_entidade){
<%if trim(strAction) = "" then %>
//ABRIU POPUP
var txt_chamada = '';
try {
var oMyObject = window.dialogArguments;
txt_chamada = "oMyObject";
var aux = oMyObject.document;
} catch (e) {
txt_chamada = "window.parent.opener";
}
try{
//COD_TS_CONTRATO
<%if trim(txt_nome_campo_cod_ts)<>"" then %>
var ocod_ts_contrato = eval(txt_chamada + ".document.form01.<%Response.write txt_nome_campo_cod_ts%>");
<%else%>
var ocod_ts_contrato = eval(txt_chamada + ".document.form01.cod_ts_contrato");
<%end if %>
if (ocod_ts_contrato != null )
ocod_ts_contrato.value = cod_ts_contrato;
//NUM_CONTRATO
<%if trim(txt_nome_campo_cod)<>"" then%>
var onum_contrato = eval(txt_chamada + ".document.form01.<%Response.write txt_nome_campo_cod%>");
<%else%>
var onum_contrato = eval(txt_chamada + ".document.form01.num_contrato");
<%end if %>
if (onum_contrato != null )
onum_contrato.value = num_contrato;
//NOME_CONTRATO
<%if trim(txt_nome_campo_desc)<>"" then%>
var onome_entidade = eval(txt_chamada + ".document.form01.<%Response.write txt_nome_campo_desc%>");
<%else%>
var onome_entidade = eval(txt_chamada + ".document.form01.nome_contrato");
<%end if%>
if (onome_entidade != null )
onome_entidade.value = nome_entidade;
<%if trim(funcao_executar) <> "" then%>
try{
var aux = eval(txt_chamada+".<%Response.write funcao_executar%>");
}catch(e){
window.returnValue = 'window.<%Response.write funcao_executar%>';
}
<%end if%>
<%if ucase(indsubmit) = "TRUE" then%>
eval(txt_chamada + ".document.form01.submit()");
<%else %>
//Somente joga o Focus se o campo existir, e estiver desabilitado
if (onum_contrato != null && onum_contrato.disabled==false && onum_contrato.enabled==true)
onum_contrato.focus();
<%end if%>
}catch(e){
//COD_TS_CONTRATO
<%if trim(txt_nome_campo_cod_ts)<>"" then %>
var ocod_ts_contrato = eval(txt_chamada + ".<%Response.write txt_nome_campo_cod_ts%>");
<%else%>
var ocod_ts_contrato = eval(txt_chamada + ".cod_ts_contrato");
<%end if %>
if (ocod_ts_contrato != null )
ocod_ts_contrato.value = cod_ts_contrato;
//NUM_CONTRATO
<%if trim(txt_nome_campo_cod)<>"" then%>
var onum_contrato = eval(txt_chamada + ".<%Response.write txt_nome_campo_cod%>");
<%else%>
var onum_contrato = eval(txt_chamada + ".num_contrato");
<%end if %>
if (onum_contrato != null )
onum_contrato.value = num_contrato;
//NOME_CONTRATO
<%if trim(txt_nome_campo_desc)<>"" then%>
var onome_entidade = eval(txt_chamada + ".<%Response.write txt_nome_campo_desc%>");
<%else%>
var onome_entidade = eval(txt_chamada + ".nome_contrato");
<%end if%>
if (onome_entidade != null )
onome_entidade.value = nome_entidade;
<%if trim(funcao_executar) <> "" then%>
/*try{
var aux = eval(txt_chamada+".<%Response.write funcao_executar%>");
}catch(e){
window.returnValue = 'window.<%Response.write funcao_executar%>';
}*/
var opener_document = oMyObject.ownerDocument;
var opener_window = opener_document.defaultView || opener_document.parentWindow;
try {
eval("opener_window." + "<%Response.write funcao_executar%>");
} catch (e) {
window.returnValue = "window." + "<%Response.write funcao_executar%>";
}
<%end if%>
<%if ucase(indsubmit) = "TRUE" then%>
eval(txt_chamada + ".submit()");
<%else %>
//Somente joga o Focus se o campo existir, e estiver desabilitado
if (onum_contrato != null && onum_contrato.disabled==false && onum_contrato.enabled==true)
onum_contrato.focus();
<%end if%>
}
parent.self.close();
<%else %>
//ABRIU NORMAL ENTAO DAR SUBMIT
document.form01.cod_ts_contrato.value = cod_ts_contrato;
document.form01.num_contrato.value = num_contrato;
document.form01.action = '<%Response.write strAction & "?PT=" & Request("PT")%>';
document.form01.submit();
<%end if %>
}
I started making the changes and look at this. In the code piece below, in the first Alert() I have the value of the variable, in the second it is not called. I believe it gets lost in this situation:
.document.form01.<%Response.write txt_nome_campo_cod_ts%>");
I think I should switch to document.getElementsByName()
. I’m trying to make the change suggested by Tobymosque, but I confess I’m having some difficulty understanding, but I think it’s the way.
try{
alert(cod_ts_contrato);
//COD_TS_CONTRATO
<%if trim(txt_nome_campo_cod_ts)<>"" then %>
var ocod_ts_contrato = eval(txt_chamada + ".document.form01.<%Response.write txt_nome_campo_cod_ts%>");
<%else%>
var ocod_ts_contrato = eval(txt_chamada + ".document.form01.cod_ts_contrato");
<%end if %>
if (ocod_ts_contrato != null )
ocod_ts_contrato.value = cod_ts_contrato;
alert(cod_ts_contrato);
So was the function with the help of Tobymosque.
function selecionar(num_contrato, cod_ts_contrato, nome_entidade){
<%if trim(strAction) = "" then %>
//ABRIU POPUP
var txt_chamada = '';
if (window.dialogArguments) {
txt_chamada = "window.dialogArguments";
} else if (window.parent.opener) {
txt_chamada = "window.parent.opener";
} else if (window.parent.frameElement) {
if (window.parent.frameElement.ownerDocument.defaultView) {
txt_chamada = "window.parent.frameElement.ownerDocument.defaultView";
} else {
txt_chamada = "window.parent.frameElement.ownerDocument.parentWindow";
}
}
try{
//COD_TS_CONTRATO
var janela = null;
if (window.dialogArguments) {
janela = window.dialogArguments;
} else if (window.parent.opener) {
janela = window.parent.opener;
} else if (window.parent.frameElement) {
var documento = window.parent.frameElement.ownerDocument
var janela = documento.defaultView || documento.parentWindow;
}
if (janela) {
var txt_nome_campo_cod_ts = "<%= trim(txt_nome_campo_cod_ts) %>" || "cod_ts_contrato";
var txt_nome_campo_cod = "<%= trim(txt_nome_campo_cod) %>" || "num_contrato";
var ocod_ts_contrato = janela.document.form01[txt_nome_campo_cod_ts];
var onum_contrato = janela.document.form01[txt_nome_campo_cod];
// var onum_contrato = janela.document.getElementsByName(txt_nome_campo_cod);
}
// //NUM_CONTRATO
}catch(e){
// Aqui código do Catch. Retirei para não ficar grande a edição.
}
parent.self.close();
$("#dialog1", janela).dialog("close");
<%else %>
//ABRIU NORMAL ENTAO DAR SUBMIT
document.form01.cod_ts_contrato.value = cod_ts_contrato;
document.form01.num_contrato.value = num_contrato;
document.form01.action = '<%Response.write strAction & "?PT=" & Request("PT")%>';
document.form01.submit();
<%end if %>
}
If anyone has any idea to work, even if it is not by jquery-ui (Modal Dialog), it is welcome, as long as the behavior of the search screen is Modal.
– pnet