Click to See Complete Forum and Search --> : PHP Vs JavaScript - Simple help


mayooresan
04-09-2008, 02:48 PM
while($row = mysql_fetch_array($r))
{


?>

<?php
echo'<td>'.$row['supID'].'</td>';
echo'<td>'.$row['supName'].'</td>';
echo'<td>'.$row['supAdd'].'</td>';
echo'<td>'.$row['supEmail'].'</td>';
echo'<td><a href="appSupHandler.php?id='.$row['supID'].'&method=Approve"> Approve</a> </td>';
echo'<td><a href="appSupHandler.php?id='.$row['supID'].'&method=Reject"> Reject</a></td>';
?>
In the above code when I click the Accept or Reject a href link, I should be promted to click ok and cancel.

if I click ok then I should be allowed to go to the a href add as given in the above php code.

<a href="appSupHandler.php?id='.$row['supID'].'&method=Approve"> Approve</a>
I think this can be done using javascript. some one please help me.

thanks in advance

LeeU
04-09-2008, 03:49 PM
Not sure what you want. Do you want someone to re-write this for you in JavaScript?

TheLanyard
04-09-2008, 04:02 PM
You can accomplish this without javascript (if I understand you correctly).

Basically, have appSupHandler.php contain a form that will store the supID that it receives from the link. Have it's 'action' attribute point to itself:

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<input type="hidden" name="id" value="<?php echo $_GET['id']; ?>" />
....confirm button code here...
</form>

And then handle the POST data however you need it. Hope this is what you're asking for. It sounds like you need a way to confirm their selection yet still pass the information. PHP is a better choice if you absolutely need the confirmation since you can always disable javascript.

felgall
04-09-2008, 09:24 PM
The owner's validation of forms always needs to be done server side. Any JavaScript validation is just there to make the form friendlier for the person filling it out.

mayooresan
04-09-2008, 11:08 PM
I think you guys didnt get my point!!

can you remember in wordpress, when you delete posts it'll show an command box asking 'are you sure you want to delete this post?' then we can click either ok, or cancel.

I want something like that for both Accept a href and reject a href!!!

shank
04-10-2008, 07:02 AM
Hi,

Try this out... may be useful...

echo'<td><a href="appSupHandler.php?id='.$row['supID'].'&method=Approve" onclick="return confirm('."'Approve?'".');"> Approve</a> </td>';
echo'<td><a href="appSupHandler.php?id='.$row['supID'].'&method=Reject" onclick="return confirm('."'Reject?'".');"> Reject</a></td>';

Hope you were asking for this, all the best!!

TheLanyard
04-10-2008, 09:30 AM
If you want a little window to pop up with 'Accept' or 'Reject', then I guess javascript is your answer. You'll have to make a script that handles the click event on the Accept/Reject links and pops up a window. If they click accept, I suppose it should submit a form similar to the one I entered above.

LeeU
04-10-2008, 09:42 AM
Here are a few scripts written in Javascript:

http://javascript.internet.com/forms/accept-terms.html

http://javascriptsource.com/forms/agree-before-entry.html

http://javascriptsource.com/forms/agree-before-posting.html

YourChild
04-11-2008, 02:48 AM
[php]<a href="appSupHandler.php?id='.$row['supID'].'&method=Approve"> Approve</a>
I think this can be done using javascript. some one please help me.

thanks in advance

Hi Mayooresan,

I think I know what you're trying to do.

This is the code for javascript:


<script language="javascript" type="text/javascript">
function doubleCheck(decision){
if(decision == 'approve'){
return true;
}
return false;
}
</script>



<?php

your code....

echo'<td><a href="appSupHandler.php?id='.$row['supID'].'&method=Approve" onclick="return doubleCheck(\'approve\')"> Approve</a> </td>';
echo'<td><a href="appSupHandler.php?id='.$row['supID'].'&method=Reject" onclick="return doubleCheck(\'reject\')"> Reject</a></td>';
?>

hope this helps