Click here to Skip to main content
11,485,294 members (75,838 online)
Click here to Skip to main content
Add your own
alternative version

Writing ASP Chat using JavaScript and XML (Part 4)

, 21 Jan 2004 81.2K 1.7K 32
The last part of the ASP chat series. This article explains how to provide a chat with multiple rooms.
<title>New message</title>
<!-- #INCLUDE FILE="INC/chatprocessing.asp" -->
var strMessage = Request.Form("Message");
var sessionID = Request.Form("SessionID");
var moodType = Request.Form("Mood");
var roomID = Request.Form("RoomID");
// Avoid empty message addition.
if((strMessage.Count > 0) && (sessionID.Count > 0) && (moodType.Count > 0) && (roomID.Count > 0)) {
	addMessage(roomID, sessionID, strMessage, moodType);
else {
	sessionID = Request("SessionID");
	roomID = Request("RoomID");
<script language="JavaScript">
function checkVoice() {
	var strText = document.frmNewMessage.Message.value;
	if(strText.length < 1 || strText.length > 500) {
		return false;
	var sessionID = document.frmNewMessage.SessionID.value;
	if(sessionID == "") {
		return false;
	return true;
function submitWithMood(moodType) {
	if(checkVoice()) {
		document.frmNewMessage.Mood.value = moodType;
<form id="frmNewMessage" name="frmNewMessage" action="newmessage.asp" 
<textarea id="Message" name="Message" cols="60" rows="3"></textarea>
<input type="Hidden" id="SessionID" name="SessionID" value="<%=sessionID%>">
<input type="Hidden" id="RoomID" name="RoomID" value="<%=roomID%>">
<input TYPE="Hidden" NAME="Mood" ID="Mood" VALUE="0">
<input type="Button" value="Send" onclick="submitWithMood(0)">&nbsp;
<a HREF="javascript:submitWithMood(1)"><img SRC="img/mood1.gif" BORDER="0" title="good" WIDTH="15" HEIGHT="15"></a>&nbsp;
<a HREF="javascript:submitWithMood(2)"><img SRC="img/mood2.gif" BORDER="0" title="bad" WIDTH="15" HEIGHT="15"></a>&nbsp;
<a HREF="javascript:submitWithMood(3)"><img SRC="img/mood3.gif" BORDER="0" title="ok" WIDTH="15" HEIGHT="15"></a>&nbsp;
<a HREF="javascript:submitWithMood(4)"><img SRC="img/mood4.gif" BORDER="0" title="malice" WIDTH="15" HEIGHT="15"></a>&nbsp;
<a HREF="javascript:submitWithMood(5)"><img SRC="img/mood5.gif" BORDER="0" title="nice" WIDTH="15" HEIGHT="15"></a><br>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Alexander Fedorenko
Web Developer
Ukraine Ukraine
Alexander Fedorenko is a professional C++ developer since 1996. He completed many custom and shareware projects. One of the successful projects is DevPlanner - tool for personal planning and time management.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.150520.1 | Last Updated 22 Jan 2004
Article Copyright 2004 by Alexander Fedorenko
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid