How to call js function from php code

kundamor

Member
Messages
36
Reaction score
0
Points
6
i have some problem with following code....
please help..

<html>
<head>
<script type=text/javascript>

function checkit(par1, para2){

if (par1=='del'){

alert ("Are you sure to delete. id:" +para2);
}
}
</script>
</head>
<body>
<form>
<?php

include_once("connect.php");

$result=sql_query("SELECT * FROM category");

while ($row=sql_fetch_row($result){

echo "<tr><td>".$row[id]."</td>";
echo "<td><input type=button id='del' valve='delete' onclick='return checkit('del','".$row[id]."')</td></tr>";

}

echo "</table>";
?>

<input type=button value='click me' name='del' onclick= return checkit('del','1002')>

</form>
</htm>

when i try it from second button "clicke me" it work but from first "delete" no activity, how can i fix it...

please help///
 

mfurqanabid

New Member
Messages
37
Reaction score
0
Points
0
checkout this modified script

<html>
<head>
<script type=text/javascript>

function checkit(par1, para2){

if (par1=='del'){

alert ("Are you sure to delete. id:" +para2);
}
}
</script>
</head>
<body>
<form>
<?php

include_once("connect.php");

$result=sql_query("SELECT * FROM category");

while ($row=sql_fetch_row($result)){

echo "<tr><td>".$row[id]."</td>";
echo "<td><input type=button id='del' valve='delete' onclick='checkit('del','".$row[id]."')</td></tr>";

}

echo "</table>";
?>

<input type=button value='click me' name='del' onclick= return checkit('del','1002')>

</form>
</html>
 

kundamor

Member
Messages
36
Reaction score
0
Points
6
thanks for reply...


ok, one think i just want to know how much client side validation is unsafe as compare to server side validation, and in which case, or on both we can rely with satisfaction....
 

xmakina

New Member
Messages
264
Reaction score
0
Points
0
Client side validation stops the user from having to resubmit the form for every mistake they make. It does not, however, validate Anything as far as you are concerned. Everything should be checked server side, especially SQL injections.
 

dickey

New Member
Messages
128
Reaction score
0
Points
0
how do you do check for SQL Injections? do you parse all entries before commiting changes?
 
Top