Form Validaton

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



Hey all,

I am having a problem intergrating a javascript validation function with the 
rest of my php script. The javascript just does not seem to read the array 
'samplemark' and true is returned on submitting the form. The info is 
inserted into the database without any problems.  This is what I have:

snip
---------------
<script language=javascript type="text/javascript">

function samplevalidate(sample) {
 if (sample.samplemark[0].value == "") {
 alert("You must enter a Sample Mark")
 sample.samplemark[0].focus()
 return false
 }
 return true
}
</script>
-------------------------

snip
--------------------
if ($samplesubmit)
{
   $x=count($labno);
   for ($i=0;$i<$x;$i++)
      {
        echo $samplemark[$i];
        $samplesubsql="INSERT INTO tblSamples SET jobno='$njn', 
labno='$labno[$i]',
        samplemark='$samplemark[$i]', comment='$comment[$i]'";

        $submitquery=mysql_query($samplesubsql) or die(mysql_error());
      }
}
------------------

snip
------------------
$seqlabno= $first_lab_no;
for ($i=0;$i<$no_of_lab_nos;$i++)
{
?>

<tr>
<td width="10%"><input type="text" size="11" name="labno[]" tabindex="-1" 
value="<?=$prefix.$seqlabno?>"></td>
<td width="40%"><input type="text" size="55" name="samplemark[]"></td>
<td width="50%"><input type="text" size="65" name="comment[]"></td>
</tr>

<?
$seqlabno++;
}
-----------------------

Any help would be greatly appreciated.

Regards
Craig

-- 
Craig Main
IT Manager
Inspectorate M&L
Tel: (011) 763-6037
Cell: (082) 323-4670
Email: craig.main@xxxxxxxxxxxxxxxx



[Index of Archives]     [Postgresql General]     [Postgresql Admin]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Yosemite Backpacking]     [Postgresql Jobs]

  Powered by Linux