1
How do I write a file. ASP if a condition in JAVASCRIPT?
NOTE: I can already write files in . ASP quiet.
Below the font piece as example:
<script>
if(1 == 2) { // ISSO É FALSO, PORTANTE ELE DEVE IR PARA O ELSE, POREM ELE FAZ TODO ASP
<%
oStream.WriteLine "ESCREVE LINHA 2"
If (1 = 1) Then 'IF DO ASP, SE 1 = 2, ELE NÃO ESCREVE , ESTÁ OK
oStream.WriteLine "ESCREVE LINHA 3"
End If
%>
} else {
<% oStream.WriteLine "ESCREVE FIM" %>
}
So when the javascript condition is false, it does not respect, and does all ASP.
The result of my file is:
...
WRITE LINE 2 /THIS SHOULD NOT HAVE
WRITE LINE 3 // NEITHER THIS
END WRITER ...
I tried to color the entire font for you to test, but I can’t, give a bug in the editor.
Actual source:
if (frm['MAPA'].window.ChecarDentroDoPonto('VEICULOS', '{<%=rs("VeiculoID")%>-<%=rsPosicao("VeiculoLogID")%>}', '{<%=strChaveRotaP%>}') == false) {
document.write('<input type="hidden" name="SQL" value="UPDATE VeiculosLogsAuxiliar SET RotaP=\'A\' WHERE PrefixoView=\'<%=rs("PrefixoView")%>\' AND VeiculoLogID=<%=rsPosicao("VeiculoLogID")%>">');
<% If IsNull(strEmailNew) = False Then
If InStr(1, strEmailNew, "@") > 0 Then %>
document.write('<input type="hidden" name="AlertaEmailVeiculoID" value="<%=rs("VeiculoID")%>">');
document.write('<input type="hidden" name="AlertaEmailAlerta" value="ROTAP<%=lngRotaPID%>-<%=lngPontoIDAtual%>">');
document.write('<input type="hidden" name="AlertaEmailEmail" value="<%=strEmailNew%>">');
document.write('<input type="hidden" name="AlertaEmailTitulo" value="<%=strEmpresa & " - ALERTA - " & rsPosicao("DtLog")%>">');
document.write('<input type="hidden" name="AlertaEmailMensagem" value="<%="Cliente: " & rs("NomeFantasia") & "<br>" & "Veículo: " & rs("VeiculoID") & " - " & rs("Placa") & " - " & rs("Descricao") & "<br>" & "Atrasado na rota \'" & strRotaPDescricao & "\'" %>">');
<%
End If
End If
%>
</script>
understood, but I have to do the condition in JS even, because I’m doing an integration with google MAPS, then I need to draw on the map a vehicle (in JS), and check in (JS) if the drawing is within the point, I will try to post a part of the code:
– vandrebr1
postei: ROYAL SOURCE, I edited the doubt
– vandrebr1
humm then does the following.. if(1=1) { $("#idElemento"). load('gravaLog01.Asp'); } Else { $("#idElement"). load('gravalog02.Asp'); }
– Dorathoto
in real source I want to replace Document.write with oStream.Writeline in ASP
– vandrebr1
edited the original answer
– Dorathoto
got it, thanks. But I think I’ll do using Activexobject("Scripting.Filesystemobject"), then I write in JS even, What do you think of this solution? Like, it’ll only work on IE, but since it’s an internal monitor, no problem.
– vandrebr1
Excellent answer, well explanatory, congratulations.
– MarceloBarbosa
vandrebr1 do not forget to mark as response
– Dorathoto