Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP and JavaScript

Status
Not open for further replies.

zzfive03

Programmer
Jun 11, 2001
267
Good Afternoon.

I am trying to make a Chat room. I am attempting to store the contents of the entire room in a database field called "room". On my client page, I have a place for the user to type data and press submit. I want my submit to save the table and then update the textarea field WITHOUT refreshing the page. To do this, I am mixing Javascript and VB(server script). How do i call a server side VB scritp from my client side scripts??

'FYI Show = Response.Write

Show &quot;<font color='blue'>&quot;
Title &quot;Chat Room!!&quot;
Show &quot;</font>&quot;
Show &quot;<table border=1><tr><td>&quot;
Show &quot;<textarea name='room' id='room' rows=20 cols=50></textarea>&quot;
Show &quot;<td valign='top'><small><b>People in Here</small></b><hr>&quot;
Show &quot;<tr><td colspan=2>&quot;
Show &quot;<textarea name='text' id='text' rows=5 cols=60 ></textarea>&quot;
Show &quot;<tr><td colspan=2><input type='button' value='Send' id='submit' name='submit'><input type='reset' value='Clear' name='clear'>&quot;

%>

<Script Language='VBScript'>
SUB submit_onClick
room.value = room.value + vbCrLf + text.value
text.value = &quot;&quot;
End Sub
'at this point, i want to call a server function that will write to the database, then update my text area with the new data.
</Script>

Any help is appreciated
 
What you're looking for is:

Remote Scripting

There are some pretty good FAQ's (3 of them) in this forum about the subject... I'm not personally familiar with the technique, but that's definitely what you need to look around for.

:)
Paul Prewett
penny.gif
penny.gif
 
Here is an simple example
But u need _ScriptLibrary from Microsoft in your current directory if u havent got it yet

Code:
This is the Start.htm page

<HTML>
<BODY>
<SCRIPT Language=&quot;JavaScript&quot; src=&quot;_ScriptLibrary/rs.htm&quot;></SCRIPT>
<SCRIPT LANGUAGE=&quot;javascript&quot;>
RSEnableRemoteScripting();
var serverURL = &quot;RSPage.asp&quot;;
function myTest()
	{
		var objtemp=RSExecute(serverURL, &quot;GetRS&quot;,&quot;My Text From Client Side&quot;,refreshPage);
	} 
function refreshPage(objRS)
{
	var rs=objRS.return_value;
	lista.innerHTML=rs;
};

</SCRIPT>
<input type=button name=rstest value=&quot; Go &quot; onclick=&quot;myTest()&quot;>
<hr>
<div name=&quot;lista&quot; id=&quot;lista&quot;></div>
</BODY>
</HTML> 

This is the RSPage.asp

<%@ LANGUAGE=VBSCRIPT %>
<!--#include file=&quot;_ScriptLibrary/rs.asp&quot;-->
<% RSDispatch %>
<SCRIPT Language=JavaScript RUNAT=SERVER>
	function Description()
	{ 
		this.GetRS = myGetRS;
	}
	public_description = new Description();


	function myGetRS(txt)
	{
	    return &quot;Your text from html was: <b>&quot;+txt+&quot;</b>;   //This will force a server-side error
	}
</SCRIPT>


Hope this is good enough.
If u need more help please tell us.

________
George, M
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top