Hello friends,
I have created a edit page in which all the values which entered earlier will be dispalyed in respective textbox and textarea.
While entering the data for the 1st time the user have to upload 3 files like transcript, reference1, reference2. They might have uploaded 1 or 2 or 3 files. On the edit page I am dispalying the files which they have uploaded earlier. If they want to upload the new file than they have to delete it first on the edit page.
Suppose the user has uploaded reference 1 earlier..and if he want to upload reference1 again than he has to delete the current file and than upload the new one.
I am able to do all this uptill now.
When they delete the transcript which is the first uploading file the javascript validation works and alerts "plz upload the transcript again". But if user delete the reference1 or reference 2 and click the submit button the javascirpt validation is not working.
Please see the atachments for solving it..thks
<script type="text/javascript">
function validate(form)
{
var at=document.getElementById("email").value.indexOf("@");
var zip=document.getElementById("zip").value;
if (form.transcripts.value == "")
{
alert("You must upload Transcripts.");
form.transcripts.focus();
return (false);
}
if (form.reference1.value == "")
{
alert("You must upload Reference 1.");
form.reference1.focus();
return (false);
}
if (form.reference2.value == "")
{
alert("You must upload Reference 2.");
form.reference2.focus();
return (false);
}
if (form.ssn.value == "")
{
alert("You must enter SSN No.");
form.ssn.focus();
return (false);
}
if (form.home_address.value == "")
{
alert("You must enter Home Address.");
form.home_address.focus();
return (false);
}
if (form.home_city.value == "")
{
alert("You must enter City.");
form.home_city.focus();
return (false);
}
if (form.home_state.value == "")
{
alert("You must enter State.");
form.home_state.focus();
return (false);
}
if (isNaN(zip)||zip<1||zip>100000)
{
alert("You must enter appropriate Zip Code.");
form.home_zip.focus();
return (false);
}
if (form.home_phone.value == "")
{
alert("You must enter Phone Number.");
form.home_phone.focus();
return (false);
}
if (at== -1)
{
alert("You must enter appropriate email.");
form.email.focus();
return (false);
}
if (form.school_name.value == "")
{
alert("You must enter School Name.");
form.school_name.focus();
return (false);
}
if (form.biographical_sketch.value == "")
{
alert("You must enter Biographical Sketch.");
form.biographical_sketch.focus();
return (false);
}
if (form.objectives.value == "")
{
alert("You must enter Objectives.");
form.objectives.focus();
return (false);
}
if (form.career_goals.value == "")
{
alert("You must enter Career Goals.");
form.career_goals.focus();
return (false);
}
if (form.plans.value == "")
{
alert("You must enter Plans.");
form.plans.focus();
return (false);
}
return (true);
}
</script>
$i=0;
while ($i < $num)
{
$t=mysql_result($result,$i,"transcript");
$r1=mysql_result($result,$i,"reference1");
$r2=mysql_result($result,$i,"reference2");
$ssn=mysql_result($result,$i,"ssn");
$address=mysql_result($result,$i,"address");
$city=mysql_result($result,$i,"city");
$state=mysql_result($result,$i,"state");
$zip=mysql_result($result,$i,"zip");
$phone=mysql_result($result,$i,"phone");
$email=mysql_result($result,$i,"email");
$school=mysql_result($result,$i,"school");
$biographical=mysql_result($result,$i,"biographical");
$objectives=mysql_result($result,$i,"objectives");
$career=mysql_result($result,$i,"career");
$plans=mysql_result($result,$i,"plans");
$comments=mysql_result($result,$i,"comments");
++$i;
}
?>
<form action="summer_application_final_submit.php" method="post" enctype="multipart/form -data" name="form" >
<table bgcolor="#3399CC" cellspacing="1" cellpadding="0" width="100%" border="0" height="100%">
<tr>
<td class="table" colspan="2" height="25%"><p><font class="news2">Summer Fellowship
Application </font></p>
<p><font class="statement">(<font color="#FF0000">*</font> indicates fields required)
  ;
  ;
  ; <a href='logout.php'>Logout</a></font><br>
<p><font class="statement">The application should be submitted no later than
<font class="red"><span class="style1">March 30th, 2005</span> at 8 PM.</font></font><br>
<font class="statement">Awardees will be notified by <font class="red">April
15th, 2005.<br>
<br>
</font></font><font class="statement">
</font>
<font class="statement"><table width="90%" border="0">
</table>
</font> </p>
<table width="90%" border="0">
<tr>
<td> <p><font class="news2"><strong>Attachments</strong></font><br>
<font class="red">Uploading New files will replace the older ones. </font>
</font></p></td>
</tr>
<tr>
<? if(!$t == '')
{
}
else{
echo '<td><font class="statement">1) Transcript Copy </font> <input type="file" name="transcripts" id="transcripts" >
<font color="#FF0000"> *</font></td>'; }?></tr>
<tr>
<? if(!$r1 == '')
{
}
else{
echo '<td><font class="statement">2) Reference Letter 1 </font> <input name="reference1" type="file" size="25" >
<font color="#FF0000"> *</font></td>'; }?>
</tr>
<tr>
<? if(!$r2 == '')
{
}
else{
echo'<td><font class="statement">3) Reference Letter 2</font> <input name="reference2" type="file" size="25"> <font color="#FF0000">*</font>
</td>';}?>
</tr>
<tr>
<td> <p></font><br>
<font class="red">List of files you have uploaded. </font>
</font></p></td>
<tr><td class='statement'>
<?
if($t == ''){}else{
echo"
1) Transcript Copy";}?> <a href='/summer_fellowship/<? echo $t; ?>'><? echo $t; ?></a>
<?if($t == ''){
}
else{
echo "<input type='Submit' name='Submit' value='Delete' onClick='javascript:subit1(1);'>";}?></font></p></td>
</tr>
<tr>
<?
if($r1 == ''){}else{
echo"
<td class='statement'>2) Reference Letter 1";}?> <a href='/summer_fellowship/<? echo $r1; ?>'><? echo $r1; ?></a>
<? if($r1 == '')
{
}
else{
echo "<input type='Submit' name='Submit' value='Delete' onClick='javascript:subit1(2);'>";}?></font></p></td>
</tr>
<tr>
<?
if($r2 == ''){}else{
echo"
<td class='statement'>3) Reference Letter 2 ";}?> <a href='/summer_fellowship/<? echo $r2; ?>'><? echo $r2; ?></a>
<? if($r2 == '')
{
}
else{
echo "<input type='Submit' name='Submit' value='Delete' onClick='javascript:subit1(3);'>
";}?></font></p></td>
</tr>
<tr>
<td align="center">
<input type='Submit' name="Submit" value="Save" onClick="javascript:subit(1);">
<input name="Submit" type="Submit" value="Send the application" onclick="return validate(form);">
</td>
</tr>
</table>
</td>
<td colspan="1" bgcolor="black" valign="top" align="left" width="123"><img src="../img/spaceship.gif" align="middle">
</td>
</tr>
</table>
</form>