1
I have posted some questions here about ASP
and js
. I received a lot of help from my colleague Tobymosque and also from Maicon. Well, with the help of both and the code that Toby gave me, I’ve made a lot of progress here in replacing ASP
for js
, and of course our goal, to make work the Modal
in the Chrome
. Well, it turns out the last form I’m having trouble with. It climbs Modal, closes correctly (one of the Modal problems in Chrome), but the fields in the calling form remain empty, not populated. I made many attempts and the one I will post was the last one at the moment. Spend all day today and I could not get anything to finish the task. I still have a lot of doubts about it and I don’t think it’s from ASP
, but rather of the js
on how to replace. The whole problem is in the ELSE
of the first IF(ASP)
. Below the original code and then what I did to replace.
function selecionar(codigo, descricao)
{
<% If Request("grid") <> "" Then %>
<% If modal= "S" then%>
if (window.dialogArguments) // Internet Explorer supports window.dialogArguments
{
var oMyObject = window.dialogArguments;
}
else // Firefox, Safari, Google Chrome and Opera supports window.opener
{
var oMyObject = parent.window.opener;
}
var oGrid = oMyObject.document.all["<%=grid%>"].object;
<% Else %>
var oGrid = window.opener.document.all["<%=grid%>"].object;
<% End If%>
<%If col_cod <> "" Then %>
oGrid.setCell(<%=linha%>,'<%=col_cod%>',codigo);
<% End If %>
<%If col_nom <> "" Then %>
oGrid.setCell(<%=linha%>,'<%=col_nom%>',descricao);
<% End If %>
<% Else %>
var txt_retorno = '';
<%if txtfuncao <> "" then%>
try{
txt_retorno = 'window.<%=txtfuncao%>;';
}catch(e){
txt_retorno = '';
}
<%end if%>
try{
window.parent.opener.document.form01.<%=codcampodisplay%>.focus();
}catch(e){}
if (BrowserDetect.browser == "Explorer"){
//if (bowser.msie){
window.returnValue = 'window.document.form01.<%=codcampodisplay%>.value="' + codigo + '";' + 'window.document.form01.<%=nomcampodisplay%>.value="' + descricao + '";' + txt_retorno;
window.parent.close();
}else{
window.parent.opener.document.form01.<%=codcampodisplay%>.value = codigo;
window.parent.opener.document.form01.<%=nomcampodisplay%>.value= descricao;
try{
window.parent.opener.document.form01.num_cnes_solicitante.focus();
} catch (e) {}
window.parent.close();
}
<% end if %>
}
Below one of the many attempts I made and it didn’t work.
var asp = {};
asp.grid = '<%= Request("grid")%>';
asp.linha = "<%= linha%>";
asp.colcod = "<%= col_cod%>";
asp.colnom = "<%= col_nom%>";
asp.txtfuncao = "<%= txtfuncao%>";
asp.codcampodisplay = "<%=codcampodisplay%>";
function selecionar(codigo, descricao) {
var janela = window.dialogArguments || window.parent.opener || window.parent.dialogArguments;
if (janela) {
var form01 = null;
if (janela.document) {
form01 = janela.document.form01;
}
else {
form01 = janela.elements;
}
var container = form01 || janela.document.opener;//isso tá errado
if (asp.grid != "") {
var oGrid = grid;
if (asp.colcod != "")
oGrid.setCell(asp.linha, asp.colcod, codigo);
if (asp.colnom != "")
oGrid.setCell(asp.linha, asp.colnom, descricao);
} else {
var txt_retorno = '';
txt_retorno = asp.txtfuncao != "" ? window.asp.txtfuncao : "";
try{
window.parent.opener.document.form01.asp.codcampodisplay.focus();
}catch(e){}
if (BrowserDetect.browser == "Explorer"){
//if (bowser.msie){
window.returnValue = 'window.document.form01.<%=codcampodisplay%>.value="' + codigo + '";' + 'window.document.form01.<%=nomcampodisplay%>.value="' + descricao + '";' + txt_retorno;
window.parent.close();
}else{
container[form01 + asp.codcampodisplay] = codigo;
container[form01 + asp.nomcampodisplay] = descricao;
try{
window.parent.opener.document.form01.num_cnes_solicitante.focus();
} catch (e) {}
window.parent.close();
}
}
}//janela
try {
window.parent.dialogWindow.close();
//janela.close();
}
catch (e) {
parent.self.close();
}
//parent.self.close();
}
I would like a help to find the path of stones.
You’re making this mistake, but I looked for an unopened key, an unopened parenthesis and so on and I don’t see anything:
Uncaught Syntaxerror: Unexpected end of input
My difficulty is in loading the variable, using the same principle that Toby gave me:
window.parent.opener.document.form01.<%=codcampodisplay%>.value = codigo;
and here
window.returnValue = 'window.document.form01.<%=codcampodisplay%>.value="' + codigo + '";' + 'window.document.form01.<%=nomcampodisplay%>.value="' + descricao + '";' + txt_retorno;
look, I don’t think I need to detect the IE in this case, the code written to the other browsers should work on the IE too, in case it would just be
container[asp.codcampodisplay].value = codigo;
– Tobias Mesquita
you don’t have to do all this rodeo with
var form01...
, just try to assignvar container = janela.document.form01;
– Tobias Mesquita
@Tobymosque, post your comment as an answer for me to accept. It worked.
– pnet