I've posted some questions here about ASP
and js
. I got a lot of help from colleague TobyMosque and also from Maicon. Well, with the help of both of them and the code that Toby gave me, I was able to evolve a lot here in replacing ASP
with js
, and of course our goal, to make Modal
work in Chrome
. Well, it turns out that the last form I'm having problems with. It climbs modally, closes properly (one of Modal's problems with Chrome), but the fields in the calling form remain empty, not populated. I made many attempts and the one I'm posting was the last one at the moment. Spend the whole day today and did not get anything to finish the task. I still have a lot of questions about it and I do not think it's about ASP
, but about js
on how to replace. The whole problem is in 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 is one of many attempts I made and it did not 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 some help finding the way to the stones.
You are giving this error, but I have searched for an unclosed key, a nonclosed parenthesis, and so on and see nothing:
Uncaught SyntaxError: Unexpected end of input
My difficulty is to load the variable, using the same principle that Toby gave me this way:
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;