...

View Full Version : document.body.innerHTML



liv
07-05-2004, 02:09 PM
The code is listed below works correctly in the IE, but in the Opera and Netscape browsers the variable htmlBody does not contain the value of the form components. How may I avoid this problem?

function onSubmit(){

if(document.forms[0].desc.value == "" ||
document.forms[0].uname.value == "" ||
document.forms[0].email.value == "" ||
document.forms[0].hphone.value == "" ||
document.forms[0].wphone.value == "" ||
document.forms[0].bldg.value == "" ||
document.forms[0].street.value == "" ||
document.forms[0].floc.value == "" ||
document.forms[0].fnum.value == "" ||
document.forms[0].atype.value == "" ||
document.forms[0].atag.value == "") {
alert("All fields must be filled out!");
return false;
}


var email = document.forms[0].email.value;
var htmlBody = document.body.innerHTML;
document.forms[0].bcc.value = window.prompt("You are already automatically sent a copy. Please enter additional CC recipients using their email address and a semicolon to seperate each:", email);
document.forms[0].body.value = htmlBody;
return true;
}
</script>
...

<form onsubmit="javascript:return(onSubmit());" method="post" >
<input type="hidden" name="recipient" value="workorders@bwc.org">
<input type="hidden" name="bcc" value="">
<input type="hidden" name="body" value="Your text should be here...">
...
</form>

sad69
07-05-2004, 11:57 PM
Try replacing your line:


var htmlBody = document.body.innerHTML;


with this one:


var htmlBody = document.getElementsByTagName('body').item(0).getAttribute('innerHTML');


I'm not sure if it'll work better or worse, but I think this the proper DOM way of accessing the BODY and its innerHTML.

I'm also not sure, but I don't think Opera supports innerHTML. I don't have Opera installed here, so I can't tell you for sure.

Hope that works,
Sadiq.

liv
07-06-2004, 10:08 AM
Thank you for helping, but it doesn't work too. I think Mozilla, Opera, Nescape
don't include the value of form components into innerHTML properties. Maybe I wrong.

Willy Duitt
07-06-2004, 10:28 AM
I do not see a form action within your codes.
Are you submitting this to the users email client?
If so, not all email clients forward the contents of a form.
This may be the problem rather than a browser issue.....

liv
07-06-2004, 02:20 PM
I give the full version of this page and included mail.jsp page below.
Detail: filled out on the form information not passed using the innerHTML properties.


<%@ page language="java" errorPage="../errorpage.jsp" contentType="text/html;charset=windows-1252"%>
<%@ page language="java" import = "oracle.jbo.html.*" %>

<script type="text/javascript">

/****************************************************************************
**
** Function: onSubmit()
** Input: none
**
** Output: none
**
** Description: Submit handler
**
***************************************************************************/

function onSubmit(){

if(document.forms[0].desc.value == "" ||
document.forms[0].uname.value == "" ||
document.forms[0].email.value == "" ||
document.forms[0].hphone.value == "" ||
document.forms[0].wphone.value == "" ||
document.forms[0].bldg.value == "" ||
document.forms[0].street.value == "" ||
document.forms[0].floc.value == "" ||
document.forms[0].fnum.value == "" ||
document.forms[0].atype.value == "" ||
document.forms[0].atag.value == "") {
alert("All fields must be filled out!");
return false;
}


var email = document.forms[0].email.value;
var htmlBody = document.body.innerHTML;
document.forms[0].bcc.value = window.prompt("You are already automatically sent a copy. Please enter additional CC recipients using their email address and a semicolon to seperate each:", email);
document.forms[0].body.value = htmlBody;
return true;
}
</script>

<%
String FullName = "";
String UserEmail = "";
String UserHomeNum = "";
String UserWorkNum = "";
String UserBuildingNumber = "";
String UserStreetName = "";
String UserFlatLocation = "";
String UserDepartment = "";

%>

<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252">
<LINK REL=STYLESHEET TYPE="text/css" HREF="/webapp/css/bc4j.css">
<TITLE>Work Order Request Form - Personal</TITLE>
</HEAD>
<BODY>
<%
RequestParameters params = HtmlServices.getRequestParameters(pageContext);

if(params.getParameter("recipient") != null) { %>
<jsp:include page="../email.jsp" flush="true">
<jsp:param name="sender" value="srs@bwc.org"/>
<jsp:param name="recipient" value='<%=params.getParameter("recipient")%>'/>
<jsp:param name="bcc" value='<%=params.getParameter("bcc")%>'/>
<jsp:param name="subject" value="Work Order Request Form - APPLIANCE"/>
<jsp:param name="contentType" value="text/html"/>
<jsp:param name="body" value='<%=params.getParameter("body")%>'/>
</jsp:include><%
}%>
<h3><font size=+2>Work Order Request Form - Personal item or appliance</font></h3>
<table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td valign="top">

<div align="center"><center>

<BR>
<table class="clsTable" cellspacing="1" cellpadding="3">
<tr class="clsTableRow" >
<td width="67%"><strong><em>Personal items</em></strong></td>
</tr>
<tr class="clsTableRow" >
<td width="67%"><strong><small>Time & resources permitting, personal items are supported
by the Department of Works to the extent of checking for and repairing simple mechanical
failures such as broken power cords. Where possible, basic troubleshooting will be done so
that you can be more informed in dealing with repair shops.&nbsp; In conjunction with the
Department of Purchasing, the Department of Works maintains a list of major appliance
repair vendors in the Haifa area. This list is available <a href="http://infoweb/works/Reference%20lists/appliancelist.xls">here</a>.</small></strong></td>
</tr>
<tr class="clsTableRow" >
<td width="67%"><strong><em>BWC-supplied appliances</em></strong></td>
</tr>
<tr class="clsTableRow" >
<td width="67%"><strong>For <u>large appliances</u>, please complete this
work order request form and type <u>&quot;9999&quot;</u> as &quot;Appliance repair tag
number&quot;. </strong><p><strong>For small appliances, please place the item in the shelves at P3 underground parking (outside the Food Centre by the walk in fridge) of the ITC, complete and
attach an appliance repair tag, <u>and</u> complete this work order request form. </strong></td>
</tr>
</table>
<BR>
</center></div>
<div align="center"><center>
<form onsubmit="javascript:return(onSubmit());" method="post" >
<input type="hidden" name="recipient" value="workorders@bwc.org">
<input type="hidden" name="bcc" value="">
<input type="hidden" name="body" value="Your text should be here...">
<table class="clsTable" cellspacing="1" cellpadding="3">
<tr class="clsTableRow" >
<td width="28%"><strong>Your name</strong></td>
<td width="70%" valign="middle"><input type="text" name="uname" size="50" tabindex="1" value="<%=FullName%>"></td>
</tr>
<tr class="clsTableRow" >
<td width="28%"><strong>Your e-mail</strong></td>
<td width="70%" valign="middle">
<input type="text" onblur="" name="email" size="50" tabindex="2" value="<%=UserEmail%>" alt="your email address"></td>
</tr>
<tr class="clsTableRow" >
<td width="28%"><strong>Telephone (home or cell)</strong></td>
<td width="70%" valign="middle"><input type="text" name="hphone" size="50" tabindex="3" value="<%=UserHomeNum%>"></td>
</tr>
<tr class="clsTableRow" >
<td width="28%"><strong>Telephone (work)</strong></td>
<td width="70%" valign="middle"><input type="text" name="wphone" size="50" tabindex="4" value="<%=UserWorkNum%>"></td>
</tr>
<tr class="clsTableRow" >
<td width="28%"><strong>Full address where work is requested</strong></td>
<td width="70%" valign="middle"><strong><small>Bldg No: </small>
<input type="text" name="bldg" size="3" tabindex="5" alt="your building number" value="<%=UserBuildingNumber%>"><small> Street Name: </small>
<input type="text" name="street" size="26" tabindex="6" alt="your street name" value="<%=UserStreetName%>"><br>

<small>Flat Location (Floor, Lt/Rt/Mid): </small>
<input type="text" name="floc" size="10" tabindex="9" alt="your flat location" value="<%=UserFlatLocation%>"></strong>
<BR><strong><small>Flat Number: </small> <input type="text" name="fnum"></strong></td>
</tr>
<tr class="clsTableRow" >
<td width="28%"><strong>Type of Appliance&nbsp; </strong></td>
<td width="70%" valign="middle">
<input type="text" name="atype" size="50" tabindex="10" alt="the type of appliance"></td>
</tr>
<tr class="clsTableRow" >
<td width="28%"><strong>Appliance repair tag number </strong></td>
<td width="70%" valign="middle">
<input type="text" name="atag" size="50" tabindex="10" alt="the appliance tag number" onblur=""></td>
</tr>
<tr class="clsTableRow" >
<td width="28%"><strong>Owned By?</strong></td>
<td width="70%" valign="middle">
<select name="owner">
<option></option>
<option>BWC</option>
<option>Personal</option>
</select>
</td>
</tr>
<tr class="clsTableRow" >
<td width="28%"><strong>Problem description</strong></td>
<td width="70%" valign="middle">
<textarea rows="10" name="desc" cols="55" tabindex="13" alt="the problem description"></textarea></td>
</tr>
<tr class="clsTableRow" >
<td colspan="2" width="70%"><strong><small>Thank you.</small></strong></td>
</tr>
</table>
<br>
<input type="Submit" value="Submit">
</form>
</center></div><u>

<p align="center">&nbsp;</u>
</td></tr></table><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td>
<div align="center"><center>

<table class="clsTable" cellspacing="1" cellpadding="3">
<tr class="clsTableRow" >
<td width="1%" height="1">
<a href="mailto:workshop"><img src="http://infoweb/works/_borders/bottom2.jpg" alt="wpe7.jpg (1118 bytes)" width="49" height="49"></a>
</td>
<td width="68%" height="1">
<strong><small>How may we be of service to
you?<br>
Click here to contact the Department of Works for more information, or to make
suggestions.</small></strong>
</td>
</tr>
</table>
</center></div>

</td></tr>
</table>
</BODY>
</HTML>


------------------email.jsp--------------------------------------------------------------------------

<%@ page language="java" errorPage="/errorpage.jsp" contentType="text/html;charset=windows-1252"%>
<%@ page import="oracle.jbo.*" %>
<%@ page language="java" import = "oracle.jbo.html.*" %>
<%@ taglib uri="/webapp/DataTags.tld" prefix="jbo" %>
<%@ taglib uri="/WEB-INF/email.tld" prefix="mail" %>

<jbo:ApplicationModule id="am" configname="org.bwc.flats.srs.bc.BcModule.BcModuleLocal" releasemode="Stateful" />

<%
if(request.getParameter("sender") == null) {
%>
<FORM METHOD=post>
<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH="20%">
<TR><TD>Host:</TD><TD><INPUT TYPE="text" name="host" ></TD></TR>
<TR><TD>From:</TD><TD><INPUT TYPE="text" name="sender" value='<%=request.getParameter("sender")%>'></TD></TR>
<TR><TD>To:</TD><TD><INPUT TYPE="text" name="recipient" value='<%=request.getParameter("recipient")%>'></TD></TR>
<TR><TD>Cc:</TD><TD><INPUT TYPE="text" name="cc" ></TD></TR>
<TR><TD>Bcc:</TD><TD><INPUT TYPE="text" name="bcc" value='<%=request.getParameter("bcc")%>'></TD></TR>
<TR><TD>Subject:</TD><TD><INPUT TYPE="text" name="subject" value='<%=request.getParameter("subject")%>'></TD></TR>
</TABLE><br>
<TEXTAREA name="body" ROWS=4 COLS=30>"Dear Sir/Madam,"</TEXTAREA><br><br>
<INPUT TYPE="submit" value="Send">
</FORM>
<%
}
else{
String contentType = request.getParameter("contentType");
if(contentType == null || contentType.equals(""))
contentType = "text/plain";
%>
<mail:sendMail host='<%=am.useApplicationModule().getSession().getEnvironment().get("SMTPHostName")%>'
sender='<%=request.getParameter("sender")%>'
recipient='<%=request.getParameter("recipient")%>'
cc='<%=request.getParameter("email")%>'
bcc='<%=request.getParameter("bcc")%>'
subject='<%=request.getParameter("subject")%>'
contentType='<%=contentType%>'>
<%=request.getParameter("body")%>
</mail:sendMail>
<script type="text/javascript">
alert("Email to <%=request.getParameter("recipient")%> was sent out successfully!");
</script>
<%
}
%>






<%--
emailEngine.send(emailCompose.getMessage());
%>
<h3><font size=+2>Email to <%=emailEngine.getTo()%> was sent successfully!</font></h3--%>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum