PDA

View Full Version : Help with forms



simbarashe
Apr 7th, 2007, 04:08 PM
I am trying to use two forms on the same page and these forms have different actions because one if for submitting and the other if for submitting the form. My code is a bit messy and its as follows:

<html>
<style type="text/css">
<!--
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
a:active {
text-decoration: none;
}
-->
</style><head>
<link href="CalendarControl.css" rel="stylesheet" type="text/css"><script src="CalendarControl.js" language="javascript"></script>
<script type="text/javascript" language="javascript">
function validate(oldClients) {
if(oldCilents.contact_name.value=="") {
msg += "\n - First name";
return false;
}
return true;
}
</script>
</head>
<body>
<?php
require_once('dbFunction.php');
?>

<form name="oldClients" method="post" action="dbNewJobsheet.php" onSubmit="displayOldInfo()">
<?php
dbConnect();

$role = mysql_query("SELECT * FROM STATUS_DESC") or die(mysql_error());
$staff = mysql_query("SELECT * FROM STAFF")
?>

<table width="98%" cellpadding="5" cellspacing="0" class="borderTop">
<td colspan="2" bgcolor="#FFCC00" align="center"><strong>Old Client Jobsheet</strong></td>
<tr>

<td align="left" width="20%" valign="top">
<table width="100%" border="2" align="left" cellpadding="5" bordercolor="#FFCC00" bgcolor="#FFFFFF">
<tr>
<td bgcolor="#FFCC00"><strong>Client Information Search </strong></td>
<tr>
<td bgcolor="#FFFFFF"><strong>Search box </strong></td>
<tr><td bgcolor="#FFFFFF"><input name="search" type="text" class="formText" /></td>
<tr><td bgcolor="#FFFFFF"><strong>Search Type</strong></td>
<tr><td align="center" bgcolor="#FFFFFF"><select name="searchOption" ><option value="0" selected="selected">select</option>
<option value="1">
JobSheet Number</option><option value="2">Company Name</option>
<option value="3">Client Name</option><option value="4">Date</option>
<option value="5">Call History</option><option value="6">Document Name</option>
</select>
</td>
<tr><td bgcolor="#FFFFFF"><strong>Start Date</strong></td>
<tr><td bgcolor="#FFFFFF"><input name="start_date" onFocus="showCalendarControl(this);" type="text"></td>
<tr><td bgcolor="#FFFFFF"><strong>Finish Date</strong></td>
<tr><td bgcolor="#FFFFFF"><input name="finish_date" onFocus="showCalendarControl(this);" type="text" /></td>
<tr><td align="center" bgcolor="#FFFFFF"><input type="submit" value="Search" name="btnSearch" /></td>
<tr><td>
<table border="2">
<tr><td align="center" bordercolor="#FFCC00"><strong>Other Tasks</strong></td>
<tr><td align="center" bordercolor="#FFCCOO"><a href="index.php?page=newStaffForm.php">Change Staff Details</a></td>
<tr><td align="center" bordercolor="#FFCC00"><a href="index.php?page=callMessage.php">Call Message</a></td>
<tr><td align="center" bordercolor="#FFCC00"><a href="index.php?page=changeCustDetails.php">Change Customer Details</a></td>
</table>



</table>
</form>
</td>
<td align="left" width="65%" valign="top">
<form here>
<table align="left" width="100%" cellpadding="5" cellspacing="0">

<tr align="center" class="formHeader">
<td width="47%" bgcolor="#FFCC00"><strong>Client details</strong>
<td width="53%" bgcolor="#FFCC00"><strong>Job sheet details</strong> </td>
</tr>
<tr>
<td valign="top" align="center">

<table cellpadding="4" class="formText">
<tr><td>Client name<td><input name="contact_name" type="text" class="input"/></td>
<tr><td>Company name<td><input type="text" name="company_name" class="input"></td>
<tr><td>Site address<td><input name="Site_address" type="text" class="input" /></td>
<tr><td>Phone number<td><input type="text" name="phone_number" class="input"></td>
<tr><td>E-mail<td><input type="text" name="email_address" class="input"></td>
</tr>
</table>
<td valign="top" align="center">

<table cellpadding="3">
<tr><td class="formText">Job Sheet Number<td class="formText">
<?php
echo JobIdGen();
?>
</td>
<tr><td class="formText">Date<td class="formText"><?php echo date("l, j F Y"); ?></td>
<tr><td class="formText">Assigned to<td>
<select name="assignedStaff">
<option value="0">Choose one</option>
<?php
while($staffRow = mysql_fetch_array($staff))
{
echo '<option value='.$staffRow['staffID'].'>'.$staffRow['username'].'</option>';
}
?>
</select>

<tr><td class="formText">Assigned Date<td>
<input name="todays_date" onFocus="showCalendarControl(this);" type="text">

<tr><td class="formText">Assigned Time<td>
<?php //<input name="assigned_time" type= "text" id= "assigned_time" class="textAreaBorder">
?>
<select name="postHour"><option value="1"> 1 </option><option selected="selected" value ="2"> 2 </option> <option value="3"> 3 </option> <option value="4"> 4 </option> <option value="5"> 5 </option> <option value="6"> 6 </option> <option value="7"> 7 </option> <option value="8"> 8 </option> <option value="9"> 9 </option> <option value="10"> 10 </option> <option value="11"> 11 </option> <option value="12"> 12 </option> </select> : <select name="postMinute"><option value="00"> 00 </option> <option value="15"> 15 </option> <option value="30"> 30 </option> <option value="45"> 45 </option> </select> <select name="postAMPM"> <option value="0"> AM </option> <option selected="selected" value="1"> PM </option> </select>

</td>
<tr><td class="formText">Time Created<td class="formText">
<?php echo strftime("%R",time());
echo ' Hours';
?>

</td>
</tr>
<tr><td>Status<td>
<select name="status">
<option value="0">Choose one</option>
<?php
while($row = mysql_fetch_array($role))
{
echo '<option value='.$row['status_desc_ID'].'>'.$row['status_type'].'</option>';
}
?>
</select>
</td>
</table>
<tr><td></td></tr>
<tr>
<td colspan="2" align="center" class="borderTop" bgcolor="#FFCC00"><span class="formHeader"> <strong>Request</strong></span></td></tr>
<tr>
<td colspan="2" align="center" class="borderTop" bgcolor="#FFCC00"><span class="formHeader">
<strong>Title :<input name="title" type="text" class="input"/></strong></span></td></tr>
<tr>
<td colspan="2" align="center"><textarea name="textarea" cols="70" rows="10" class="textAreaBorder"></textarea></td></tr>
<tr>
<tr><td colspan="2" align="center" class="borderTop" bgcolor="#FFCC00">
<input type="button" name="clear" value="Clear" class="button" onClick="validate(oldClients);" >
<input type="submit" name="submit" value="Submit" class="button">
</td></tr>
</table>
</td>
</tr>

</table>
</td>
</tr>
</table>
</form>
</body>
</html>

I've just highlighted where I want to put the for actions, is this the best option because it stuffs up my page, could some1 please advise me on how to do it

Tahnk you

twodayslate
Apr 7th, 2007, 05:54 PM
From what I gather you want two forms. One is where the user types and such and the other to submit.

You do not need two forms for that, only one.

http://www.htmlgoodies.com/tutorials/forms/article.php/3479121
http://www.w3.org/TR/html4/interact/forms.html