two javascript functions in html not working...help please!

K

KathyB

Hi, I'm have two (what I thought were simple) javascripts in an hmtl
form. I believe I'm totally missing the boat on how I'm referring to
the parameter variables or something. My first function (ValidateItem)
looks like it just posts back to the form with no actions taken, the
second (ConfirmSave) looks like it is just ignored and the
ValidateSave.aspx page loads without the user confirming.

With ValidateItem, I'm simply trying to validate a number against a
min and max before passing the form onto an aspx page for processing.

The ConfirmSave function I simply want to include the text entered in
the input box in a confirm message to the user, then process upon
true.

Sorry, I'm pretty new at this...any help greatly appreciated!

Thanks, kathy


*************HTML*****************

<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-16">
<style type="text/css">
bgcolor="#FFFFFF"
h1 {font-family: Gill Sans MT;color: blue;font-size:20pt
font-weight:bold;margin-top:0;margin-bottom:0}
h2 {font-family: Gill Sans MT;color: red;font-size:18pt
font-weight:bold;margin-top:0;margin-bottom:0}
h3 {font-family: Gill Sans MT;color:
white;font-size:14pt;font-weight:bold;margin-top:0;margin-bottom:0}
body {font-family: Gill Sans MT;color: black;font-size:12pt}
p {font-family: Gill Sans MT;color: black;font-size:12pt}
h4 {font-family: Gill Sans MT;color:
white;font-size:12pt;font-weight:bold;text-transform:
uppercase;margin-top:0;margin-bottom:0}
h5 {font-family: Gill Sans MT;color:
white;font-size:12pt;font-weight:bold;margin-top:0;margin-bottom:0}
h6 {font-family: Gill Sans MT;color:
black;font-size:12pt;font-weight:bold;margin-top:0;margin-bottom:0}
</style>
<title>Example of XSLT</title><script language="Javascript">
function Anomaly(typeIn,idIn,textIn)
{
newWindow = window.open(('Anomaly.aspx?type='+typeIn+'&id='+idIn+'&text='+textIn),
'Anomaly', 'width=650,height=700,left=100,toolbar=no,menubar=no,resizable=yes');
}
</script><script>
function ValidateItem(item,min,max)
{
if((parseInt(item.value) != item.value) || item.value < min ||
item.value > max)
{
alert("The entry must be between " +min+ " and " +max+ ".");
item.focus();
item.select();
return false;
}
else
{
confirm("You are about to enter: " +item.value+ " -- are you
sure?");
return true;
}
}
</script><script>
function ConfirmSave(item)
{
if ((item.value.length==0) || (item.value==null))
{
alert("You are trying to save a blank entry.");
item.focus();
item.select();
return false;
} }
else {
confirm("You are about to enter: " +item.value+ " -- are you
sure?");
return false;
}
}
</script></head>
<body>
<h1>Test Work Instruction One</h1>
<form method="POST">
<table border="1" width="100%" cellpadding="4">
<tr bgcolor="navy" valign="middle">
<th align="left" colspan="4">
<h3>PROCESS STEPS</h3>
</th>
<tr onMouseOver="this.bgColor = '#99FFCC'" onMouseOut="this.bgColor =
'#FFFFFF'">
<td align="center" valign="middle"><input style="CURSOR: HAND"
type="button" value="Anomaly"
onclick="Javascript:Anomaly('Step','1','Step one of the work
instruction.')"></td>
<td valign="top">
<table width="100%" border="0" cellpadding="0">
<tr>
<td valign="top" width="7">
<table border="0" cellpadding="0">
<tr>
<td valign="top" width="7">  </td>
<td valign="top">1.  </td>
</tr>
</table>
</td>
<td>
<p>Step one of the work instruction.</p>
</td>
</tr>
</table>
</td>
</tr>
<tr onMouseOver="this.bgColor = '#99FFCC'" onMouseOut="this.bgColor =
'#FFFFFF'">
<td align="center" valign="middle"><input style="CURSOR: HAND"
type="button" value="Anomaly"
onclick="Javascript:Anomaly('Step','2','Step two of the work
instruction.')"></td>
<td valign="top">
<table width="100%" border="0" cellpadding="0">
<tr>
<td valign="top" width="7">
<table border="0" cellpadding="0">
<tr>
<td valign="top" width="7">  </td>
<td valign="top">2.  </td>
</tr>
</table>
</td>
<td>
<p>Step two of the work instruction.</p>
</td>
</tr>
</table>
</td>
</tr>
<tr onMouseOver="this.bgColor = '#99FFCC'" onMouseOut="this.bgColor =
'#FFFFFF'">
<td align="center" valign="middle"><input style="CURSOR: HAND"
type="button" value="Anomaly"
onclick="Javascript:Anomaly('Step','2.1','Step two-one goes
here.')"></td>
<td valign="top">
<table width="100%" border="0" cellpadding="0">
<tr>
<td valign="top" width="77">
<table border="0" cellpadding="0">
<tr>
<td valign="top" width="77">  </td>
<td valign="top">2.1  </td>
</tr>
</table>
</td>
<td>
<p>Step two-one goes here.</p>
</td>
</tr>
</table>
</td>
</tr>
<tr onMouseOver="this.bgColor = '#99FFCC'" onMouseOut="this.bgColor =
'#FFFFFF'">
<td align="center" valign="middle"><input style="CURSOR: HAND"
type="button" value="Anomaly"
onclick="Javascript:Anomaly('Step','2.2','Step two-two goes
here.')"></td>
<td valign="top">
<table width="100%" border="0" cellpadding="0">
<tr>
<td valign="top" width="77">
<table border="0" cellpadding="0">
<tr>
<td valign="top" width="77">  </td>
<td valign="top">2.2  </td>
</tr>
</table>
</td>
<td>
<p>Step two-two goes here.</p>
</td>
</tr>
</table>
</td>
</tr>
<tr onMouseOver="this.bgColor = '#99FFCC'" onMouseOut="this.bgColor =
'#FFFFFF'">
<td align="center" valign="middle"><input style="CURSOR: HAND"
type="button" value="Anomaly"
onclick="Javascript:Anomaly('Step','2.2.1','Step two-two-one
here.')"></td>
<td valign="top">
<table width="100%" border="0" cellpadding="0">
<tr>
<td valign="top" width="147">
<table border="0" cellpadding="0">
<tr>
<td valign="top" width="147">  </td>
<td valign="top">2.2.1  </td>
</tr>
</table>
</td>
<td>
<p>Step two-two-one here.</p>
</td>
</tr>
</table>
</td>
</tr>
<tr onMouseOver="this.bgColor = '#99FFCC'" onMouseOut="this.bgColor =
'#FFFFFF'">
<td align="center" valign="middle"><input style="CURSOR: HAND"
type="button" value="Anomaly"
onclick="Javascript:Anomaly('Step','3','Step three of the work
instruction. A test measurement here: ')"></td>
<td valign="top">
<table width="100%" border="0" cellpadding="0">
<tr>
<td valign="top" width="7">
<table border="0" cellpadding="0">
<tr>
<td valign="top" width="7">  </td>
<td valign="top">3.  </td>
</tr>
</table>
</td>
<td>
<p>Step three of the work instruction. A test measurement here: <form
id="test_measure" action="parent.hidden.location=ValidateSave.aspx"
method="post" onsubmit=" return
ValidateItem('test_measure','1','5')"><input style="CURSOR: HAND"
type="text" size="5" name="test_measure" value="">mm  
<input type="submit" value="SAVE"><input type="hidden"
name="LoRange" value="1" size="10"><input type="hidden" name="HiRange"
value="5" size="10"></form>
</p>
</td>
</tr>
</table>
</td>
</tr>
<tr onMouseOver="this.bgColor = '#99FFCC'" onMouseOut="this.bgColor =
'#FFFFFF'">
<td align="center" valign="middle"><input style="CURSOR: HAND"
type="button" value="Anomaly"
onclick="Javascript:Anomaly('Step','4','Step four of the work
instruction with a test data collection entry: ')"></td>
<td valign="top">
<table width="100%" border="0" cellpadding="0">
<tr>
<td valign="top" width="7">
<table border="0" cellpadding="0">
<tr>
<td valign="top" width="7">  </td>
<td valign="top">4.  </td>
</tr>
</table>
</td>
<td>
<p>Step four of the work instruction with a test data collection
entry: <form id="test_data"
action="parent.hidden.location=ValidateSave.aspx" method="post"
onsubmit="return ConfirmSave('test_data')"><input style="CURSOR: HAND"
type="text" name="test_data" value="">  
<input type="submit" value="SAVE"></form>
</p>
</td>
</tr>
</table>
</td>
</tr>
<tr onMouseOver="this.bgColor = '#99FFCC'" onMouseOut="this.bgColor =
'#FFFFFF'">
<td align="center" valign="middle"><input style="CURSOR: HAND"
type="button" value="Anomaly"
onclick="Javascript:Anomaly('Step','5','Last step, number
five.')"></td>
<td valign="top">
<table width="100%" border="0" cellpadding="0">
<tr>
<td valign="top" width="7">
<table border="0" cellpadding="0">
<tr>
<td valign="top" width="7">  </td>
<td valign="top">5.  </td>
</tr>
</table>
</td>
<td>
<p>Last step, number five.</p>
</td>
</tr>
</table>
</td>
</tr>
</tr>
<tr bgcolor="red" valign="middle">
<td align="center" valign="middle"><input type="button" name="Finish"
value="FINISH" onclick="parent.hidden.location='hidden_birth2.aspx?finish=yes'"></td>
<td align="left"><font color="white"><b>Click the FINISH button when
work instruction is complete.</b></font></td></tr>
</table>
</form>
</body>
</html>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top