Results 1 to 4 of 4
-
18th Apr 2012, 04:48 AM #1OP
form validation problem [help need]
i want to validate a form field that is an array of input but is not working even input field is not showing
please help me
here is my form in php validation
PHP Code:<?php
include("header.php");
?>
<?php
session_start();
$class=$_SESSION['class']=$_POST['class'];
$sess=$_SESSION['session'] = $_POST['session'];
$sub=$_SESSION['subject'] = $_POST['subject'];
$term=$_SESSION['term'] = $_POST['term'];
include("config.php");
$query="SELECT * FROM student_information WHERE class='$class'";
$result = mysql_query($query);
$num_rows = mysql_num_rows($result);
// initialization
$photo_upload_fields = "";
$counter = 1;
// default number of fields
$number_of_fields = $num_rows;
// If you want more fields, then the call to this page should be like,
// preupload.php?number_of_fields=20
if( $_GET['number_of_fields'] )
$number_of_fields = (int)($_GET['number_of_fields']);
// Firstly Lets build the Category List
echo"<h1>class:$class</h1>";
echo"<br/>";
echo"<h1>session:$sess</h1>";
echo"<br/>";
echo"<h1>subject:$sub</h1>";
echo"<br/>";
echo"<h1>term:$term</h1>";
// Lets build the Photo Uploading fields
while( $counter <= $number_of_fields )
{
$row1 = mysql_fetch_row($result);
$sid = $row1['1'];
$photo_upload_fields .=<<<__HTML_END
<tr>
<td>
roll {$counter}:<input name='marks[]' type='text' />// want to validate
<input type='hidden' name='roll[]' value='$counter'/>
</td>
</tr>
<tr>
<td>
<input name='sid[]' type='hidden' value='$sid'/>
</td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td>
<input name='sub[]' type='hidden' value='$sub'/>
</td>
</tr>
<tr>
<td>
<input name='sess[]' type='hidden' value='$sess'/>
</td>
</tr>
<tr>
<td>
<input name='class[]' type='hidden' value='$class'/>
</td>
</tr>
<tr>
<td>
<input name='term[]' type='hidden' value='$term'/>
</td>
</tr>
__HTML_END;
$counter++;
}
// Final Output
echo <<<__HTML_END
<html>
<head>
<title>insert classtest marks</title>
<script language="JavaScript" type="text/javascript">
<!--
function checkform ( form )
{
if (form.marks.value == "") {
alert( "Please enter marks." );
form.marks.focus();
return false ;
}
// ** END **
return true ;
}
//-->
</script>
</head>
<body>
<form action='marksentry1.php' method='post' name='upload_form' onSubmit="return checkform(this);">
<table width='90%' border='0' align='center' style='width: 90%;'>
<tr>
<td>
<p> </p>
</td>
</tr>
<!-Insert the photo fields here -->
$photo_upload_fields
<tr>
<td>
<input type='submit' name='submit' value='Add marks' />
</td>
</tr>
</table>
</form>
</body>
</html>
__HTML_END;
?>shakac Reviewed by shakac on . form validation problem [help need] i want to validate a form field that is an array of input but is not working even input field is not showing please help me here is my form in php validation <?php include("header.php"); ?> <?php session_start(); $class=$_SESSION=$_POST; $sess=$_SESSION = $_POST; Rating: 5
-
18th Apr 2012, 04:54 AM #2MemberWebsite's:
imdber.org justpaste.metr/td breaks the form. Try using div's instead.
-
18th Apr 2012, 05:21 AM #3OP
thank apathetick for your fast reply
please i tried it but form did not show
please help
-
18th Apr 2012, 12:44 PM #4Respected MemberWebsite's:
DL4Everything.com Soft2050.inReplace checkform javascript function:
PHP Code:function checkform ( form )
{
if (form.marks.value == "") {
alert( "Please enter marks." );
form.marks.focus();
return false ;
}
// ** END **
return true ;
}
PHP Code:function checkform ( form )
{
if (form.elements["marks[]"].value == "") {
alert( "Please enter marks." );
form.elements["marks[]"].focus();
return false ;
}
// ** END **
return true ;
}
Sponsored Links
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
Phone Validation
By Myth? in forum PayzaReplies: 3Last Post: 10th Mar 2012, 04:45 PM -
Form Validation, and AJAX APIs?
By ciachn in forum Polling PlazaReplies: 0Last Post: 16th Feb 2012, 02:08 PM -
W3C validation? Does it really matter? Not always!
By AriGold in forum Webmaster DiscussionReplies: 3Last Post: 6th Jun 2011, 09:11 AM -
Problem using javascript in form field
By abhikala1 in forum Web Development AreaReplies: 4Last Post: 19th Apr 2011, 10:52 PM -
Feed Validation Problem??
By Mulana in forum Technical Help Desk SupportReplies: 0Last Post: 10th Apr 2011, 03:11 PM
themaCreator - create posts from...
Version 3.24 released. Open older version (or...