OK.. I have an html form with 2 issues #1. The reset button doesn't work. #2 when you complete the form and click submit it should place the contents on the clipboard (for pasting) later then clear the fields(that works fine except for the clearing the fields part). Please help!!!! (see below)...
Edited by Von Pookie
Code:
<html>
<head>
<script language=javascript>
function autotab(max, field) {
if (!/^\d+$/.test(field.value)) { //digits only
field.value = '';
return false;
}
if (field.value.length<max)
return true; //still room
var el, e = 0, f = field.form;
while (el = f.elements[e++])
if (el == field) break; //find field position
f.elements[e].focus(); //move focus
return false;
}
function copytext() {
if (document.forms[0].RequestedCreditAmount.value=='') {
alert('Please enter Requested Credit Amount.');
document.forms[0].RequestedCreditAmount.focus();
return false;
}
if (document.forms[0].AppliedCreditAmount.value=='') {
alert('Please enter Applied Credit Amount.');
document.forms[0].AppliedCreditAmount.focus();
return false;
}
if (document.forms[0].AccountNumber.value=='') {
alert('Please enter Account Number.');
document.forms[0].AccountNumber.focus();
return false;
}
if (document.forms[0].MTN1.value==''){
alert('Please enter the area code of the MTN.');
document.forms[0].MTN1.focus();
return false;
}
if (document.forms[0].MTN2.value==''){
alert('Please enter the area code of the MTN.');
document.forms[0].MTN2.focus();
return false;
}
if (document.forms[0].MTN3.value==''){
alert('Please enter the range of the MTN.');
document.forms[0].MTN3.focus();
return false;
}
if (document.forms[0].ReasonCode.value=='') {
alert('Please enter Reason Code.');
document.forms[0].ReasonCode.focus();
return false;
}
if (document.forms[0].Date.value=='') {
alert('Please enter Date.');
document.forms[0].Date.focus();
return false;
}
if (document.forms[0].Details.value=='') {
alert('Please enter Details.');
document.forms[0].Details.focus();
return false;
}
document.forms[0].txtcopy.value = ("Your credit request has been approved and applied. We have remarked the account and attached a summary of what was done. Please allow up to two billing cycles for the credit to reflect on the account.\n\n" +
"\t\t\t\tRequested credit amount: " + document.forms[0].RequestedCreditAmount.value + "\n" +
"\t\t\t\tApplied credit amount: " + document.forms[0].AppliedCreditAmount.value + "\n\n" +
"Account #: " + document.forms[0].AccountNumber.value + "\n" +
"MTN: " + document.forms[0].MTN1.value + "-" + document.forms[0].MTN2.value + "-" + document.forms[0].MTN3.value + "\n" +
"Reason Code: " + document.forms[0].ReasonCode.value + "\n" +
"Date: " + document.forms[0].Date.value + "\n\n" +
"Details: \n" + document.forms[0].Details.value + "\n\n\n" +
"Do not reply to this email. Replies will not be answered. If you have any questions regarding your credit request, Please contact your supervisor");
t=document.forms[0].txtcopy.createTextRange();
t.select();
t.execCommand('copy');
//document.forms[0].reset();
return true;
}
</script>
<body>
<table width=95% border=0 cellspacing=0 cellpadding=0>
<form name="frmARC">
<tr>
<td colspan=2 align=center><font size=5>Approved Credit Response</font></td>
</tr>
<tr>
<td colspan=2 align=center><hr></td>
</tr>
<tr>
<td width=40% valign=top align=right>Requested credit amount:</td>
<td align=left><input name="RequestedCreditAmount" size=8 maxlength=8></td>
</tr>
<tr>
<td width=40% valign=top align=right>Applied credit amount:</td>
<td align=left><input name="AppliedCreditAmount" size=8 maxlength=8></td>
</tr>
<tr>
<td width=40% valign=top align=right>Account Number:</td>
<td align=left><input name="AccountNumber" size=15 maxlength=15></td>
</tr>
<tr>
<td width=40% align=right>MTN:</td>
<td><input type=text name="MTN1" maxlength=3 size=3 onkeyup="return autotab(3, this)"><input type=text name="MTN2" maxlength=3 size=3 onkeyup="return autotab(3, this)"><input type=text name="MTN3" maxlength=4 size=4 onkeyup="return autotab(4, this)"></td>
</tr>
<tr>
<td width=40% align=right>Reason Code:</td>
<td><input type=text name="ReasonCode" maxlength=4 size=4></td>
</tr>
<tr>
<td width=40% align=right>Date:</td>
<td><input type=text name="Date" size=12 maxlenght=12></td>
</tr>
<tr>
<td width=40% valign=top align=right>Details:</td>
<td><textarea name="Details" rows=3 cols=45 wrap></textarea></td>
</tr>
<tr>
<td colspan=2 align="center">
<input type="button" value="Submit" onclick="copytext();">
<input type=button value="Reset" onclick="cleartext();">
<input type=hidden name="txtcopy">
</td>
</tr>
</form>
</table>
</body>
</html>
Edited by Von Pookie