Jump to content


Photo

Calling a javascript function from php

php form java script function

  • Please log in to reply
1 reply to this topic

#1 alena1347

alena1347

    Advanced Member

  • Members
  • PipPipPip
  • 44 posts

Posted 28 January 2013 - 11:46 PM

I need to call a javascript or a php function from a form made in php, so that I could make change in data base on clicks.
1)I included the function on onclick event on submit but nothing happens.
2)The file name in which this code is include is view_users.php

could someone hel me solve this




<?php

mysql_select_db("programmers") or die(mysql_error());

$data = mysql_query("SELECT * FROM user_allotment")
or die(mysql_error());

while($info = mysql_fetch_array( $data ))
{
echo "<tr>";
echo "<td>".$info['id'] . "</td>";
echo "<td>".$info['uname'] . "</td> ";
echo "<td>".$info['password'] . "</td>";
$id=$info['id'];
echo "<form method="post" action="view_users.php">";
echo "<td><label><input type="button" name=/"$id/" value="edit" align="middle" onclick="edit()"/></label></td>";
echo "<td><label><input type="button" name=/"$id/" value="delete" align="middle" onclick="edit()"/></label></td>";
echo "<td><label><input type="checkbox" name=/"$id/" value="privilege" align="middle" onclick="edit()"/></label></td>";
echo "</form>";
echo "</tr>";
}
?>

#2 trq

trq

    Advanced Member

  • Administrators
  • 31,019 posts
  • LocationSydney, Australia.

Posted 29 January 2013 - 12:44 AM

Events execute on the browser, while PHP executes on the server.

http://thorpesystems.com | http://proemframework.org | http://github.com/trq

SmtpCatcher - A very simple mock sendmail useful for testing PHP mail scripts.
OPM - My Linux package manager.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com