Transfer Text across Textareas (1 Viewer)

B

bherring

Guest
I am wanting to develop an online student reporting system for teachers. Each teacher would have comment banks. When they click a statement it is transfered into the report section for the current student. Special characters in the statement for name, his/her, he/she, etc will need to be replaced with the appropriate word.

Any ideas how to tackle this?
 

Kodo

"The Shoe"
Local time
Today, 02:36
Joined
Jan 20, 2004
Messages
707
would this be a list selection type scenario?
Teacher has dropdown list of generic comments.
Teacher clicks item in list.. blank comment box gets filled in dynamically without posting a form.

Is that the type of scenario are you shooting for?
 
B

bherring

Guest
The teacher may have a dropdown list of comments. However, they should be able to select a comment, it gets transfered to text area, then any other comments they choose gets added to the end of what ever is already in the text area, or cursor location.
Also, the general comments will have markers in them for things like name, he/she, his/her, him/she. When a comment is transfered to the text area, these markers should be replace with the appropriate word for the current record.

e.g. General comment - @Name is a very naughty child. ~ should be punished.

When chosen may become - Brad is a very naughty child. He should be punished.
 

Kodo

"The Shoe"
Local time
Today, 02:36
Joined
Jan 20, 2004
Messages
707
This can be done with Javascript. You'll need to make a function that grabs the current listbox item and appends it to the the text area. In that function you will replace the markers with the appropriate text. I would recommend something like [STUDENT_NAME] and [STUDENT_SEX] as example markers.

I don't have time to write it for you as I have to move on to work however, if you'd like to give it a whirl, this is a good place to start.
http://www.quirksmode.org/js/forms.html
 
B

bherring

Guest
Thanks Kodo that was a great start. I have managed to get the text to append, I just need the replacement now, which I cant figure out. Can you take a look at my code and suggest. Much appreciated.

<html>
<head>
<script language="javascript" type="text/javascript">
function addtext() {
var newtext = myform.mymenu.options[myform.mymenu.selectedIndex].value;
;
document.myform.outputtext.value += newtext ;
}
</script>
</head>
<body>
<form name="myform">
<table border="0" cellspacing="0" cellpadding="5"><tr>
<td> <select name="mymenu" size="1">
<option value="Hello">Hello</option>
<option value="Next">Next</option>
<option value="@Name another">Another</option>
</select>
<input type="button" value="Add New Text" onClick="addtext();"></p>
</td>
<td><textarea name="outputtext"></textarea></td>
</tr></table>
</form>

</body>
</html>
 

Kodo

"The Shoe"
Local time
Today, 02:36
Joined
Jan 20, 2004
Messages
707
Rock with this and see if you can get it to work with your code.


<html>
<head>
<script language="javascript" type="text/javascript">
function addtext() {
var newtext = document.getElementById("mymenu").options[document.getElementById("mymenu").selectedIndex].value;

document.getElementById("outputtext").value += ProperReplace(newtext) ;
}

function ProperReplace(val)
{
val=val.replace(/\[Student Name\]/,'John Doe');
val=val.replace(/\[Male\]/,'He');
val=val.replace(/\[Female\]/,'She');
return val;
}
</script>
</head>
<body>
<form name="myform">
<table border="0" cellspacing="0" cellpadding="5"><tr>
<td> <select name="mymenu" id="mymenu" size="1">
<option value="Hello">Hello</option>
<option value="Next">Next</option>
<option value="[Student Name]">Another</option>
<option value="[Male]">Male</option>
<option value="[Female]">Female</option>
</select>
<input type="button" value="Add New Text" onClick="addtext();"></p>
</td>
<td><textarea id="outputtext" name="outputtext" rows="5" cols="18"></textarea></td>
</tr></table>
</form>

</body>
</html>
 
B

bherring

Guest
You are an absolute superstar!! thank you.
I have now gone a little further and used a recordset. I can get the name of the current record to be inserted. However, what I really need it to do is look at the Gender-Code field and obviously use her/she if is is "F" and vis versa for "M". Ive tried various if statements and just cant get it to work. If I can get this then it is done.
Thanks

<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="Connections/connDB_Email.asp" -->
<%
Dim rstStudent__MMColParam
rstStudent__MMColParam = "2597"
If (Request("MM_EmptyValue") <> "") Then
rstStudent__MMColParam = Request("MM_EmptyValue")
End If
%>
<%
Dim rstStudent
Dim rstStudent_numRows

Set rstStudent = Server.CreateObject("ADODB.Recordset")
rstStudent.ActiveConnection = MM_connDB_Email_STRING
rstStudent.Source = "SELECT * FROM [Pupil Data] WHERE PNUM = " + Replace(rstStudent__MMColParam, "'", "''") + ""
rstStudent.CursorType = 0
rstStudent.CursorLocation = 2
rstStudent.LockType = 1
rstStudent.Open()

rstStudent_numRows = 0
%>
<html>
<head>
<script language="javascript" type="text/javascript">
function addtext() {
var newtext = document.getElementById("mymenu").options[document.getElementById("mymenu").selectedIndex].value;

document.getElementById("outputtext").value += ProperReplace(newtext) ;
}

function ProperReplace(val)
{
val=val.replace(/\[Student\]/,'<%=(rstStudent.Fields.Item("Forename").Value)%>');
if (<%=(rstStudent.Fields.Item("Gender-Code").Value)%> == "F")
val=val.replace(/\[He\]/,'Her');
val=val.replace(/\[He\]/,'He');
val=val.replace(/\[Female\]/,'She');
return val;
}
</script>
</head>
<body>
<p> </p>
<form name="myform">
<table width="488" border="0" cellpadding="5" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="76" height="34" valign="top">Report for: </td>
<td colspan="2" align="right" valign="top"><%=(rstStudent.Fields.Item("Forename").Value)%></td>
<td colspan="2" align="left" valign="top"><%=(rstStudent.Fields.Item("Surname").Value)%></td>
<td colspan="2" valign="top"><%=(rstStudent.Fields.Item("Gender- Code").Value)%></td>
</tr>
<tr>
<td height="71"> </td>
<td width="16"> </td>
<td width="115"> </td>
<td width="21"> </td>
<td width="102"> </td>
<td width="30"> </td>
<td width="35"> </td>
</tr>
<tr>
<td height="195" colspan="2" valign="top"> <select name="mymenu" id="select" size="10">
<option value="Hello">Hello</option>
<option value="Next">Next</option>
<option value="[Student] is good. [He] loves this">Student Name</option>
<option value="[Male]">Male</option>
<option value="[Female] is a fantastic student">Female</option>
</select> <p></p></td>
<td colspan="2" valign="top"><input name="button" type="button" onClick="addtext();" value="Add New Text"></td>
<td colspan="2" valign="top"><textarea id="textarea" name="outputtext" rows="5" cols="18"></textarea></td>
<td> </td>
</tr>
</table>
</form>
<p> </p>
<p> </p>
</body>
</html>
<%
rstStudent.Close()
Set rstStudent = Nothing
%>
 

Users who are viewing this thread

Top Bottom