0

i am trying to submit a form in javascript,
and then process it in php. and it will not work. can you please help? this is the code:

<?php
if ($_POST['markcomplete']=='yes'){
		$taskid=$_POST['taskid'];
		$query="UPDATE tasks SET status='0' WHERE uid='$id' AND id='$taskid'";
        $result=mysql_query($query);
		if ($result){
			echo "<script>location.href='?goto=taskmanager'</script>";
		}else{
			echo"fail";
		}
	}
while($row=mysql_fetch_array($result)){
if($color==1){
?>
<form name='markcomplete' method=post>
<input type='hidden' value=yes name=markcomplete>
<input type='hidden' value=<?php echo $row['id']; ?> name='taskid' id='taskid'>
<td style='width: 200px;text-align: left; padding-left: 20px;'><?php if ($row['status']=='1'){ echo"<a href='javascript: document.markcomplete.submit();' class='task'> Mark complete</a>"; }else{ echo"Complete!"; } ?></td><td>
</form>
<?php
$color="2";
}else {
?>
<form name='markcomplete' method=post>
<input type='hidden' value=yes name=markcomplete>
<input type='hidden' value=<?php echo $row['id']; ?> name='taskid' id='taskid'>
<td style='text-align: left; padding-left: 20px;'><a href='javascript: document.markcomplete.submit();' class='task'>Mark complete</a></td><td style='width: 30px;'>
</forM>
<?php
$color="1";
}
}
?>

i think there is something wrong with the javascript, but im not sure. please help

3
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by varun931
0

Hi,

Firstly, do you have to use JavaScript to submit the form? This isn't especially useful for users who do not have JS enabled.

The problem I would think is because you have the element "markupcomplete" twice in your source code, on lines 24 and 25. It is possible that the JavaScript is trying to submit the input element, rather than the form.

R.

0

hi

give the name to the forms n submit it

document.forms["formname"].submit();

may this will help...

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.