How can i assign javascript variable to vbscript variable

家住魔仙堡 提交于 2019-12-12 01:20:59

问题


How can i assign the text1 value(javascript value) to vbscript variable so that i can write that data into a text file using ts.WriteLine(av)

I tried submitting the form and getting all the values in the next .asp page and then writing it to a text file, but my value has many alpha-numeric and special characters....so I cant achieve in that way..any help please.

<% Option Explicit
Const Filename = "/project.txt"    ' file to read
Const ForReading = 1, ForWriting = 2, ForAppending = 3
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
Dim FSO
set FSO = server.createObject("Scripting.FileSystemObject")
Dim Filepath
Filepath = "E:\applications\FTP\project.txt"
if FSO.FileExists(Filepath) Then
    Dim file    
    set file = FSO.GetFile(Filepath)
Dim TextStream
    Set TextStream = file.OpenAsTextStream(ForReading, TristateUseDefault)
     %>

    <form id="ValidForm"  action="">
<input type="textbox" name="ac" id="ac" value="">
    <textarea rows="100" cols="230" contenteditable>

<%  Do While Not TextStream.AtEndOfStream  
        Dim Line
        Line = TextStream.readline
        Line = Line & vbCRLF
 Response.write Line
Loop
%>
</textarea>
</form >
<%
Response.Write "</pre><hr>"
    Set TextStream = nothing
End If
Set FSO = nothing
%>

<button onclick=abc();>save</button>
<script type="text/javascript" >
function abc()
{alert("1");
var contenteditable = document.querySelector('[contenteditable]'),
text1 = contenteditable.textContent;
//document.getElementById("ac").value=text1;
alert(text1);
}
</script>

<%
'what i should add here to get the javascript variable(text1)

set fs=Server.CreateObject("Scripting.FileSystemObject")
set ts = fs.CreateTextFile("E:\\applications\\FTP\\shivan123.txt",true)
ts.WriteLine("This is my first FileSystemObject application.")
ts.WriteLine( )
ts.Close()
set ts=nothing
set fs=nothing
%>

来源:https://stackoverflow.com/questions/39138983/how-can-i-assign-javascript-variable-to-vbscript-variable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!