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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to make the default show up in the next page ?

Status
Not open for further replies.

Ngai88

Programmer
Sep 8, 2004
56
US
Hello,
I have 2 pages, composeMessage.jsp & replyMessage.jsp pages. On the composeMessage.jsp, user composes his message, and there is a dropdown box which contains a list of recipients. User selects one as primary recipient. When user does the select primary, the checkbox with the same recipient name will automatically checked itself. User then hit submit to send the message. Now the primary recipient received the message, he reply the message, the replyMessage page has the exact layout like the composeMessage page. User can conintue to use the same pre-selected primary recipient from the original composer and leave it as shown selected primary the same in the dropdown box and checked box checked when he is in reply message page. My question is how do you make the default(selected primary and checked box checked in composeMessage page)to show up in the replyMessage page?
I am wondering if there is something else in the javascript I have to do in the composeMessage.jsp as well as in the replyMessage.jsp.

thanks for the help,
Ngai

==========================================================
replyMessage.jsp

=========================================================
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@ page import="com.phoneix.cms.controller.MessageComposeController" %>
<%@ taglib uri="/expresso" prefix="expresso" %>
<%@ taglib uri="/urgent" prefix="urgent" %>
<expresso:setup type="String" id="webappContextPath" property="ContextPath" />
<urgent:urgentSetup type="String" id="expressoServer" property="ExpressoServer" />
<%@ page info="urgent Thin Client" %>
<html>
<head>
<title>Reply Message</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript" src="cms/javascript/menu.js"></script>
<script type="text/javascript">
function verifyForm(form) {
var error = "Error(s):\n\n";
if (form.<%=MessageComposeController.SUBJECT %>.value == "") {
error += "<%=MessageComposeController.SUBJECT %> is a required field.\n";
}
var hasRecipient;

for(i=0; i < form.<%=MessageComposeController.RECIPIENT %>.length; i++) {
if (form.<%=MessageComposeController.RECIPIENT %>.checked) {
hasRecipient = true;
break;
}
}
if (!hasRecipient) {
error += "<%=MessageComposeController.RECIPIENT %> is a required field.\n";
}

if (error != "Error(s):\n\n") {
alert(error);
return false;
}

if (form.<%=MessageComposeController.PRIMARY_RECIPIENT %>.selectedIndex <= 0) {
alert("You must select a PRIMARY RECIPIENT from the dropdown");
return false;
}else {
return true;
}
}

<!-- Begin
function checkAll(chkboxList){
for (i = 0; i < chkboxList.length; i++) {
chkboxList.checked = true ;
document.frmReply.isAllChecked.value = "true";

}
}

function unCheckAll(chkboxList){
for (i = 0; i < chkboxList.length; i++) {
chkboxList.checked = false ;
}

CheckPrimary(document.frmReply.tmpPrimary,chkboxList);
document.frmReply.isAllChecked.value = "false";
}

function CheckPrimary(primaryRecipient,chkboxList){
var primary = primaryRecipient.value;
var oldPrimary = document.frmReply.tmpPrimary.value;

for (i = 0; i < chkboxList.length; i++) {

if (oldPrimary == chkboxList.value){
if ("false" == document.frmReply.isAllChecked.value){
chkboxList.checked = false ;
}
}

if (primary == chkboxList.value){
chkboxList.checked = true ;
}
}
document.frmReply.tmpPrimary.value = primary;
}

// End -->

</script>
<link rel="stylesheet" href="cms/css/site.css" type="text/css">
<link rel="stylesheet" href="cms/css/menu.css" type="text/css">
<link rel="stylesheet" href="cms/css/mmm/mmm.css" type="text/css">
</head>
<urgent:bodyMenu name="mmm">
<table class="menu">
<expresso:IfElementExists name="blockMenuItems" type="block">
<expresso:Block name="blockMenuItems">
<tr class="menu">
<td class="menu">
<a href='<%= webappContextPath %>/mmm_read.do?<expresso:TransitionParamsTag name="ReadMessage"/>'>Read Message</a><br>
<a href='<%= webappContextPath %>/mmm_compose.do?<expresso:TransitionParamsTag name="ComposeMessage"/>'>Compose Message</a>
</td>
</tr>
</expresso:Block>
</expresso:IfElementExists>
</table>
</urgent:bodyMenu>
<div id="Logo">
<table><tr><td><img alt="urgent" src="<%= webappContextPath %>/images/TCLogo3.png" class="TCLOGO"></td></tr></table>
</div>
<div id="MainPage">
<form name ="frmReply" method="post" ENCTYPE="multipart/form-data" action='<%= webappContextPath %>/mmm_compose.do?<expresso:TransitionParamsTag name="Confirm"/>' onSubmit="return verifyForm(this);">
<expresso:IfErrorExists><div class="errorCollection"><expresso:ErrorTag /></div></expresso:IfErrorExists>
<expresso:IfElementExists name="BlockMessage" type="block">
<expresso:Block name="BlockMessage">
<table>
<tr>
<td class="submit">
<input type="submit" name="submit" value="Submit">
</td>
<td class="title" width="100%" colspan="5">Reply Message</td>
</tr>
<TR>
<TD class="info">Subject</TD>
<TD class="tableCell" colspan="5">
<input type="text" name="<%=MessageComposeController.SUBJECT %>" size="55" maxlength="80" value='<expresso:OutputTag name="<%=MessageComposeController.OUT_SUBJECT %>"><expresso:ContentTag/></expresso:OutputTag>'>
</TD>
</TR>
<TR>
<TD class="info">Message Body</TD>
<TD class="tableCell" colspan="5">
<textarea name="<%=MessageComposeController.MSG_BODY %>" rows="10" cols="70" Maxlength="254"><expresso:OutputTag name="<%=MessageComposeController.OUT_BODY %>"><expresso:ContentTag/></expresso:OutputTag></textarea>
</TD>
</TR>
<TR>
<TD class="info">Priority</TD>
<TD class="tableCell">
<expresso:InputTag name="<%=MessageComposeController.PRIORITY %>"/>
</TD>
<TD class="info">Message Type</TD>
<td class="tableCell">
<expresso:InputTag name="<%=MessageComposeController.MSG_TYPE %>"/>
</td>
</TR>
</TABLE>
<TABLE>

<TR>
<TD class="description">Select Primary Recipient</TD>
<TD class="tableCell">
<select name="<%=MessageComposeController.PRIMARY_RECIPIENT %>" onchange="CheckPrimary(this, document.frmReply.<%=MessageComposeController.RECIPIENT %>)"/>
<option selected>--Select--</option>
<% int blockNum = 0; %>
<expresso:ElementCollection type="block">
<expresso:ElementIterator>
<% String blockName = MessageComposeController.BLOCK + blockNum; %>
<expresso:Block name="<%= blockName %>">
<expresso:OutputTag name="<%=MessageComposeController.OUT_RECIPIENT %>">
<option value="<expresso:AttributeTag name="<%=MessageComposeController.FUNCTION_NAME %>"/>"><expresso:AttributeTag name="<%=MessageComposeController.FUNCTION_NAME %>"/></option>
</expresso:OutputTag>
</expresso:Block>
<% blockNum++; %>
</expresso:ElementIterator>
</expresso:ElementCollection>
</select>

</TD>
</TR>

<TR>
<TD class="info" colspan="2">Recipient&nbsp;
<input type="button" name="check" value="Check All" onClick="checkAll(document.frmReply.<%=MessageComposeController.RECIPIENT %>)">&nbsp;
<input type="button" name="unCheck" value="Uncheck All" onClick="unCheckAll(document.frmReply.<%=MessageComposeController.RECIPIENT %>)">
</TD>
</tr>
<expresso:ElementCollection type="block">
<expresso:ElementIterator>
<% String blockName = MessageComposeController.BLOCK + blockNum; %>
<expresso:Block name="<%= blockName %>">
<expresso:IfElementExists name="<%=MessageComposeController.OUT_RECIPIENT %>" type="outputtag">
<%if(blockNum%2==0){%>
<tr>
<%}%>
<TD class="tableCell">
<expresso:OutputTag name="<%=MessageComposeController.OUT_RECIPIENT %>">
<INPUT TYPE="CHECKBOX" NAME="<%=MessageComposeController.RECIPIENT %>" VALUE='<expresso:AttributeTag name="<%=MessageComposeController.FUNCTION_NAME %>"/>'<expresso:AttributeTag name="<%=MessageComposeController.CHECKED %>"/>>
<expresso:AttributeTag name="<%=MessageComposeController.FUNCTION_NAME %>"/>&nbsp;
</expresso:OutputTag>
</TD>
<%if(blockNum%2==1){%>
</tr>
<%}%>
</expresso:IfElementExists>
</expresso:Block>
<% blockNum++; %>
</expresso:ElementIterator>
</expresso:ElementCollection>
</TR>
<tr>
<td class="tableCell" colspan="2">Choose A File to Post:&nbsp;&nbsp;
<INPUT TYPE="File" NAME="FileIn">
</td>
</tr>

<tr>
<td class="submit" colspan="2">
<input type="submit" name="submit" value="Submit">
</td>
</tr>
</TABLE>
</expresso:Block>
</expresso:IfElementExists>
<input type="hidden" name="tmpPrimary" value="">
<input type="hidden" name="isAllChecked" value="false">
</form>
</div>
</body>
</html>
 
This would have to be done server-side, assuming that the sender is stored server-side. The select would look like this (pseudocode):

Code:
print '<select name="primaryRecipient">'

for each possible primary recipient as currentRecipient
  print '<option value="' + currentRecipient + '"'
  if currentRecipient equals sender
    print ' selected="selected"'
  print '>' + currentRecipient + '</option>';
repeat

Is that at all what you're looking for?

--Chessbot

"See the TURTLE of enormous girth!"
-- Stephen King, The Dark Tower series
 
This would have to do server-side, assuming you store the sender's name. The select would look something like this (PHP):
Code:
echo '<select name="primaryRecipient">';

foreach ($possibleRecipient as $currentRecipient)
{
  echo "<option value=\"$currentRecipient\"";
  if ($currentRecipient == $sender)
    echo ' selected="selected"';
  echo ">$currentRecipient</option>";
}

echo '</select>';

It this at all what you meant?

--Chessbot

"See the TURTLE of enormous girth!"
-- Stephen King, The Dark Tower series
 
I think I get the idea, the only thing is my program do not use PHP. There is the jsp, js, and java. Is there something similar to 'echo' in js or java?

thanks
Ngai
 
Echo simply prints the value to the page. I don't know jsp.

--Chessbot
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top