Forums
This topic is locked
Replace she/her if Female
05 Feb 2006 04:27:21 Brad BIS posted:
I have a form which transfers text from a list to a textarea. There is also a recordet attached to show one student. I can get the name to be inserted on transfer but a need it to check a Gender_Code field and substitute he/she, his/her, him/her appropriately. Help please!!<%@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
%>
Edit/Delete Message