View Full Version : Form PHP/Javascript tabbed pane

Apr 21st, 2007, 12:48 PM
Hi to all,

I am new to javascript, I have the following code(below), which has two tabbed panes and like wise have no problem in displaying the contents, But when we come across the validation part, I get an error saying :

document.forms... is null or not an object..

(Help appreciated)
Thanks in advance for your spare time and expertise

require_once ("checksession.php");
require_once ("../config.php");
require_once ("../classes/database.php");
$db = new database();

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>MGH ::: <?php echo $type;?></title>
<link href="logo.css" rel="stylesheet" type="text/css">
<script language="JavaScript" type="text/JavaScript">
//a public function that the container uses to pass in values for the labels
function public_Labels(label1, label2){
t1.innerText = label1;
t2.innerText = label2;
//a public function that the container uses to pass in values for the card containers
function public_Contents(contents1, contents2){
t1Contents.innerHTML = contents1;
t2Contents.innerHTML = contents2;
//sets the default display to tab 1
function init(){
tabContents.innerHTML = t1Contents.innerHTML;
//this is the tab switching function
var currentTab;
var tabBase;
var firstFlag = true;
function changeTabs(){
if(firstFlag == true){
currentTab = t1;
tabBase = t1base;
firstFlag = false;
if(window.event.srcElement.className == "tab"){
currentTab.className = "tab";
tabBase.style.backgroundColor = "white";
currentTab = window.event.srcElement;
tabBaseID = currentTab.id + "base";
tabContentID = currentTab.id + "Contents";
tabBase = document.all(tabBaseID);
tabContent = document.all(tabContentID);
currentTab.className = "selTab";
tabBase.style.backgroundColor = "";
tabContents.innerHTML = tabContent.innerHTML;

function getAttachment(form_name)
alert("Enter Attachment");
return false;
return true;

<BODY onclick="changeTabs()" onload="init()">
<div align="center">
<div align="center">
<TD ID=t1 CLASS=selTab HEIGHT=25 WIDTH="15%">Items</TD>
<TD ID=t2 CLASS=tab HEIGHT=25 WIDTH="15%">Facilities</TD>
<TD ID=t3 CLASS=noTab STYLE="background-color:white"></TD>
<TD ID=t1base STYLE="height:2; border-left:solid thin white"></TD>
<TD ID=t2base STYLE="height:2; background-color:white"></TD>
<TD ID=t3base STYLE="height:2; background-color:white"></TD>
<TD HEIGHT="*" COLSPAN=3 ID=tabContents
STYLE="border-left:solid thin gray;
border-bottom:solid thin gray;
border-right:solid thin gray">sample contents</TD>

<!-- ITEMS TAB -->
<DIV CLASS=conts ID=t1Contents>
<table width="800" border="1" cellpadding="1" cellspacing="0" bordercolor="#CCCCCC">
<tr align="center" valign="middle">
<td width="30%" class="boldtext">Item</td>
<td width="10%" class="boldtext">Code</td>

<DIV CLASS=conts ID=t2Contents>
<table width="800" border="1" cellpadding="1" cellspacing="0" bordercolor="#cccccc">
$facilitydisplay = $order->getDisplayfacility($orderid); //search for all the records w.r.t order id
foreach($facilitydisplay as $facidisply)
$faciattachments = $order->getFacility1($facidisply['facility_code'],$orderid); // search for all the order id records with attachments
echo "<tr valign=\"top\" class=\"e".($faccount & 1)."\">";
foreach($faciattachments as $attachments)
$filename = $attachments['file_name'];
$attachment = $attachments['attachment'];
<td width="55%" align="left" class="text"> Attachments:
<td valign="top" align="right">
<?php $attachment_form_name = 'attachment'.$faccount; ?>
<form name="<?php echo $attachment_form_name; ?>" method="post" action="" enctype="multipart/form-data" onSubmit="return getAttachment('<?php echo $attachment_form_name; ?>');">
<input name="attachment" type="file" class="text" size="35">
<input name="Submit" type="submit" class="buttonstyle" value="Attach">

with regards,