AzBuka
asked on
How to call Javascript from the server using Response.Write"window.document.writeln
Hi,
I have ASP application.
I need to call Javascript from the server using Response.Write "window.document.writeln(' <script language='Javascript'>')".
I tried this: Response.Write"window.docu ment.write ln('<scrip t" + " language" + "='javascript'" + ">)" but still doesn't work.
Can I call it some how?
I have ASP application.
I need to call Javascript from the server using Response.Write "window.document.writeln('
I tried this: Response.Write"window.docu
Can I call it some how?
or if it's only to display the value, you can always try like:
Response.Write "hello world.."
Response.Write "hello world.."
Response.Write"window.docu ment.write ln('<sc'+' ript'" + " language" + "='javascript'" + ">)"
And do the closing tag as: '</scr+ipt>'
If javascript sees the script tag is stops executing the rest of the script.
Cd&
And do the closing tag as: '</scr+ipt>'
If javascript sees the script tag is stops executing the rest of the script.
Cd&
ASKER
Hi COBOLdinosaur,
I tried this one but still doesn't work.
It returns:
at the begining: window.document.writeln(')
then several window.document.writeln( with my result value)
end finaly at the end: window.document.writeln(") ;
The javascript client side has 2 text boxes (user and password) 3 dropdown menus and submit button. On click first I am validating client input if not empty I am sending to the server. In the server I am using VBScript. I am connectiong to the database check if user and password are OK then write to the DB their input. Next based on selected combination of dropdown menues I am opening appropriate recordset and input results into table. I am creating this table on the server using Response.Write "newWindow.document.writel n('<table Width=100% VALIGN=CENTER ALIGN=CENTER>');" etc.
I can see the result but it is not in a table form. This is because when result is back to the client I will need to call Javascript .
Initialy in the server side everithing was inside a function but request.form sent empty string when I click on submit button. When I click second time everiting was fine. I want to remove this second click.Thus in the client side I removed call to the function and in the server side I removed 'function' and 'end function' .
I tried this one but still doesn't work.
It returns:
at the begining: window.document.writeln(')
then several window.document.writeln( with my result value)
end finaly at the end: window.document.writeln(")
The javascript client side has 2 text boxes (user and password) 3 dropdown menus and submit button. On click first I am validating client input if not empty I am sending to the server. In the server I am using VBScript. I am connectiong to the database check if user and password are OK then write to the DB their input. Next based on selected combination of dropdown menues I am opening appropriate recordset and input results into table. I am creating this table on the server using Response.Write "newWindow.document.writel
I can see the result but it is not in a table form. This is because when result is back to the client I will need to call Javascript .
Initialy in the server side everithing was inside a function but request.form sent empty string when I click on submit button. When I click second time everiting was fine. I want to remove this second click.Thus in the client side I removed call to the function and in the server side I removed 'function' and 'end function' .
i didnt think you could access the window object when running javascript on the server, since the window object is a client side thing.
You cannot do a response back like that. Only client side scripting can dynamically modify the page, all you end up sending back to the browser is a string that it might recognize as HTML and attempt to render, but at that point the page is badly broken and invalid.
Trying to dynamically generate client side scripting is one thing but trying to control client dynamics from the server is not going to happen. Generate a valid response page and send it back. cient side function have to be inside script tags.
Cd&
Trying to dynamically generate client side scripting is one thing but trying to control client dynamics from the server is not going to happen. Generate a valid response page and send it back. cient side function have to be inside script tags.
Cd&
ASKER
Thank you for your comments. Seems this will be a tough one. Actulally it is possible to generate table in the server running VBScript and send it back to the client running javascript and render it there. The call should be INSIDE javascript function. As I said before it works but requires 2 clicks that is annoying and unacceptable.Will not work if we use POST or GET.
If we can go around this problem. Is it possible to send Javascript variables or inputs from the form and submit them to the VBfunction on the server before POST or GET. Last night I found 2 solutions for Remote Scripting. They presented a code but this is far beyond my comprehension.
I need something more trivial . I need to send for instance user and passwords input to the server VB function before POST or GET. I think this will solve the problem.Any code ideas?
If we can go around this problem. Is it possible to send Javascript variables or inputs from the form and submit them to the VBfunction on the server before POST or GET. Last night I found 2 solutions for Remote Scripting. They presented a code but this is far beyond my comprehension.
I need something more trivial . I need to send for instance user and passwords input to the server VB function before POST or GET. I think this will solve the problem.Any code ideas?
ASKER
I am sending web links that I found about Remote Scripting(accessing the server and exchange data without POST or GET.
First Link:
http://www-106.ibm.com/developerworks/web/library/wa-exrel/
Second link:
http:// www.learnasp.com/learn/remotescripting.asp
The second solution looks more easy but I still cannot make it to work for me. I need to send user input from the form from INSIDE Javascript function to the server FUNCTION. Server is running VBScript.
OR
if I don't use Remote scripting how with post or get to call javascript from the server.
THKS
First Link:
http://www-106.ibm.com/developerworks/web/library/wa-exrel/
Second link:
http:// www.learnasp.com/learn/remotescripting.asp
The second solution looks more easy but I still cannot make it to work for me. I need to send user input from the form from INSIDE Javascript function to the server FUNCTION. Server is running VBScript.
OR
if I don't use Remote scripting how with post or get to call javascript from the server.
THKS
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
There should be some way to on the client side running on javascript to send user input to the server running on VBScript. Based on input on the server appropriate database to be opened and the information to be displayed in table form. Any ideas?
ASKER
Nothing is impossibe!
I found a solution by myself. Just write cookies on client side + submit() before post. Then read coockies and send input to the server. Now I am getting values and processing on the server then create table there and send it back to the client where javascript renders the table.
I would like to allocate 30 points to Cobol for his good comment about client side security issue. The rest of the points I would like to credit myself to use for my next question.
THKS
I found a solution by myself. Just write cookies on client side + submit() before post. Then read coockies and send input to the server. Now I am getting values and processing on the server then create table there and send it back to the client where javascript renders the table.
I would like to allocate 30 points to Cobol for his good comment about client side security issue. The rest of the points I would like to credit myself to use for my next question.
THKS
Thanks AzBuka and Sean.
BTW, I got number 6, a little earlier today. :^)
Cd&
BTW, I got number 6, a little earlier today. :^)
Cd&
That's fantastic Cd&...
A much more exclusive group of experts if you ask me :-)
Well Done.
A much more exclusive group of experts if you ask me :-)
Well Done.
There are 15 of us. :^) I guess I am going to have to start answering in XML to get #7.
Cd&
Cd&
Response.Write "<script language='Javascript'> window.document.writeln('h