PDA

View Full Version : Need a javascript to process the output of this form



gavinv3
10-18-2007, 02:28 AM
Hi Guy's,
I am Gavin, I am creating a simple form. like the one below. This is for making notes - however this one uses php - i want to use javascript for this to work as it not going to be a client server thing. - its basically to make notes or complete documentation on troubleshooting issues quickly. Below is the form and the next post is the outcome of the form.

Could you guys help me with a javascript that will help me achieve this.


<HTML><HEAD><TITLE>DSLAM RESET</TITLE>
<link href="../../../default.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.style3 {color: #000000}
.style5 {font-size: 10pt; color: black; background-color: #EFEFEF;
font-family: Arial, Verdana, Helvetica, sans-serif;}
-->
</style>
</HEAD>
<SCRIPT>
var dSlam = false;
var mOdem = false;
var dId = false;
<!-- this script is for checking for required fields --theDVZ -->
function verify() {
var themessage = "Please complete the following fields: ";


if (document.getElementById("Username").value=="") {
themessage = themessage + " - Username";
}


var isChecked = false;
for(i = 0; i < document.dslamFRM.HastheDSLAMbeenResetbefore.length;i++)
{
if(document.dslamFRM.HastheDSLAMbeenResetbefore[i].checked == true)
isChecked = true;
}
if(isChecked == false)
themessage = themessage + " - Has the DSLAM been Reset before";

if (document.getElementById("PreviousResetPRs").value == "" && dSlam)
{
themessage = themessage + " - List previous Reset PRs";
}

var isChecked = false;
for(i = 0; i < document.dslamFRM.Numberofphonesockets.length;i++)
{
if(document.dslamFRM.Numberofphonesockets[i].checked == true)
isChecked = true;
}
if(isChecked == false)
themessage = themessage + " - Number of phone sockets";

if (document.getElementById("CPEcurrentlyconnected").value=="") {
themessage = themessage + " - CPE currently connected";
}

var isChecked = false;
for(i = 0; i < document.dslamFRM.Samemodemusedaslastreset.length;i++)
{
if(document.dslamFRM.Samemodemusedaslastreset[i].checked == true)
isChecked = true;
}
if(isChecked == false)
themessage = themessage + " - Is it the same modem used as last
reset";

if (document.getElementById("DIFmodem").value == "" && mOdem) {
themessage = themessage + " - Type / Model of different Modem";
}

var isChecked = false;
for(i = 0; i <
document.dslamFRM.Modemsamesocketsincelastreset.length;i++)
{
if(document.dslamFRM.Modemsamesocketsincelastreset[i].checked == true)
isChecked = true;
}
if(isChecked == false)
themessage = themessage + " - Is the Modem in the same phone socket
since last reset";

var isChecked = false;
for(i = 0; i < document.dslamFRM.didit.length;i++)
{
if(document.dslamFRM.didit[i].checked == true)
isChecked = true;
}
if(isChecked == false)
themessage = themessage + " - Did the DSLAM reset resolve the issue";

if (document.getElementById("actioN").value == "Troubleshoot as per
Procedure" && dId) {
themessage = "NO IFMS REQUIRED AS NOT RESOLVED - Troubleshoot as per
Fault Type";
}

//alert if fields are empty and cancel form submit
if (themessage == "Please complete the following fields: ") {
return true;
}
else {
alert(themessage);
return false;
}
}
</SCRIPT>
<BODY>
<table width="600" border="0" align="center" cellpadding="5">
<tr>
<td class="emphasis2"><strong>I need a script that will convert the information
filled in the following fields to appear like in the next file</strong></td>
</tr>
<tr>
<td class="emphasislite"><strong> This is an actual working form - the only
issue is this one is using a php on the server end - what I want is a javascript
which does not need a backend that will proces the form as you see in the
next page [code pasted]</strong></td>
</tr>
</table>

<form name=dslamFRM enctype='multipart/form-data' action='process.php'
method='post' onSubmit="javascript: return verify(); ">
<table width='600' border=0 align="center" cellpadding="5">
<tr class="table">
<td width='323'><strong> Name : </strong></td>
<td width='251'>
<input type=text name='Username' id='Username'></td></tr>
<tr class="table">
<td width='323'><strong> Has the clock been Reset before : </strong></td>
<td width='251'>
<input name="HastheDSLAMbeenResetbefore" type="radio" value="YES"
onClick="document.getElementById('hide1').style.display = 'inline'; dSlam
= true;"><b>Yes
<input name="HastheDSLAMbeenResetbefore" type="radio" value="NO"
onClick="document.getElementById('hide1').style.display = 'none'; dSlam =
false;">No</b></td>
</tr>
<tr class="table" id="hide1" style="display:none">
<td width='323'><strong>If <span class="redbold">YES</span> above,
List previous Reset PRs :<br>
</strong></td>
<td width='251'>
<textarea name='PreviousResetPRs' rows=5 cols=10></textarea></td></tr>

<tr class="table">
<td width='323'><strong> Number of watches : </strong></td>
<td width='251'>
<input name="Numberofphonesockets" type="radio" value="1"><b>1
<input name="Numberofphonesockets" type="radio" value="2">2
<input name="Numberofphonesockets" type="radio" value="3">3
<input name="Numberofphonesockets" type="radio" value="4">4
<input name="Numberofphonesockets" type="radio" value="5 or More">5
or More</b></td>
</tr>
<tr class="table">
<td width='323'><strong> Please explain the nature of the defect</strong></td>
<td width='251'>
<textarea name='CPEcurrentlyconnected' id='CPEcurrentlyconnected'
rows=10 cols=35></textarea></td></tr>
<tr class="table">
<td width='323'><strong> Is it the same watch used : </strong></td>
<td width='251'>
<input name="Samemodemusedaslastreset" type="radio" value="YES"
onClick="document.getElementById('hide2').style.display = 'none'; mOdem =
false;"><b>Yes
<input name="Samemodemusedaslastreset" type="radio" value="NO"
onClick="document.getElementById('hide2').style.display = 'inline'; mOdem =
true;">No</b></td>
</tr>

<tr class="table" id="hide2" style="display:none">
<td><strong>Type / Model of the watch</strong></td>
<td><input name='DIFmodem' type=text id='DIFmodem'
size="20"></td>
</tr>



<tr class="table">
<td width='323'><strong> Is the watch in the same box : </strong></td>
<td width='251'><input name="Modemsamesocketsincelastreset"
type="radio" value="YES"><b>Yes
<input name="Modemsamesocketsincelastreset" type="radio"
value="NO">No</b></td>
</tr>
<tr class="table">
<td width='323'><strong> Did the change satisfy the customer: </strong></td>
<td width='251'>
<input name="didit" type="radio" value="YES"
onClick="document.getElementById('hide3').style.display = 'none'; dId = false;"><b>Yes
<input name="didit" type="radio" value="NO"
onClick="document.getElementById('hide3').style.display = 'inline'; dId = true;">No</b></td>
</tr>


<tr class="table" id="hide3" style="display:none">
<td><strong class="redbold"> If NO ACTION TO TAKE ==&gt;
</strong></td>
<td>
<input name='actioN' type=text id='actioN' readonly
value="Troubleshoot " size="32">
</td>
</tr>


</table>
<div align="center">
<input type='submit' value='Generate Template'>
<input type=reset value='Clear Form'>
</div>
</form>
</BODY></HTML>

gavinv3
10-18-2007, 02:29 AM
This is the output of the form

<script language="JavaScript">
// Copy and Clear Function
function ClipBoard(){
Copied = dump.createTextRange();
Copied.execCommand("RemoveFormat");
dump.select();
Copied.execCommand("Copy");
}
</script>


<link href="../../../default.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.style1 {font-family: "Comic Sans MS"}
-->
</style>


<h2 class="emphasis">COMPLETED </h2>
<br />
<table width="600" border="1" align="center" class="table">
<tr>
<td>
<div align="center" class="table"> <br />
<textarea cols="60" rows="10" name="dump">
Name : fff
Has the clock been Reset before : B4: NO
Number of watches : 3
Please explain the nature of the defect ffff
Is it the same watch used : YES
clock in same socket since last reset: YES
Is the watch in the same box :YES</textarea>
<br>
<input type="button" value="Copy Above for IFMS COMMENTS"
name="capture" onclick="ClipBoard()">
<br><br>

<input type="button" value="Return to Template" name="back"
onclick="window.location='form1.html'">

<br />
<br />
<br />
</div></td>
</tr>
</table>