+ Reply to Thread
Results 1 to 6 of 6

Thread: How to call js function from php code

  1. #1
    kundamor is offline x10Hosting Member kundamor is an unknown quantity at this point
    Join Date
    Oct 2008
    Posts
    36

    How to call js function from php code

    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///

  2. #2
    mfurqanabid's Avatar
    mfurqanabid is offline x10Hosting Member mfurqanabid is an unknown quantity at this point
    Join Date
    Mar 2008
    Posts
    37

    Re: How to call js function from php code

    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>

  3. #3
    kundamor is offline x10Hosting Member kundamor is an unknown quantity at this point
    Join Date
    Oct 2008
    Posts
    36

    Re: How to call js function from php code

    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....

  4. #4
    mfurqanabid's Avatar
    mfurqanabid is offline x10Hosting Member mfurqanabid is an unknown quantity at this point
    Join Date
    Mar 2008
    Posts
    37

    Re: How to call js function from php code

    Server side validation is more stronger than client side.

  5. #5
    xmakina's Avatar
    xmakina is offline x10 Lieutenant xmakina is an unknown quantity at this point
    Join Date
    May 2008
    Location
    England
    Posts
    265

    Re: How to call js function from php code

    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.
    IF($this->$post.content() == "SEE SIG"){
    w3Schools and Google
    }

  6. #6
    dickey's Avatar
    dickey is offline x10 Sophmore dickey is an unknown quantity at this point
    Join Date
    Sep 2008
    Location
    Singapore
    Posts
    128

    Re: How to call js function from php code

    how do you do check for SQL Injections? do you parse all entries before commiting changes?
    Don't get me wrong as I believe if and when I help someone I also help myself whereby whatever someone learns I also learn.

    But I will also accept credits or reps if you really want to part with it.

+ Reply to Thread

Similar Threads

  1. how can i convert Php pages and code into asp pages and code
    By n4tec in forum Scripts & 3rd Party Apps
    Replies: 11
    Last Post: 01-10-2009, 09:40 PM
  2. Call to undefined function domxml_open_file()
    By phpasks in forum Programming Help
    Replies: 6
    Last Post: 09-04-2008, 01:52 AM
  3. Replies: 3
    Last Post: 04-17-2008, 07:39 PM
  4. Easy XHTML form validation using PHP
    By Xemnas in forum Tutorials
    Replies: 0
    Last Post: 01-08-2008, 04:29 AM
  5. php mail function not working
    By aenman in forum Free Hosting
    Replies: 1
    Last Post: 10-26-2007, 11:16 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers