SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2007
    Posts
    97
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    call function php in javascript

    i have function in php :
    function multiple($a, $b) {
    $c = $a * $b;
    return $c;
    }

    how should i do to multiple using button
    <input type='button' onclick = 'call()' value='multiple' />

    <script>
    function call() {
    }
    </script>

    how should i code in call() ? to call function multiple in php ???

    thanx

  2. #2
    SitePoint Guru Ruben K.'s Avatar
    Join Date
    Jun 2005
    Location
    Alkmaar, The Netherlands
    Posts
    693
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    AJAX is what you're looking for

  3. #3
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,631
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    For something as simple as that then you just make the function in Javascript. :?
    Ian Anderson
    www.siteguru.co.uk

  4. #4
    SitePoint Member Aedus's Avatar
    Join Date
    Nov 2007
    Location
    Abu Dhabi, UAE
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    <script type="text/javascript">
    function product(a,b)
    {
    return a*b;
    }
    </script>

  5. #5
    SitePoint Addict hiddenpearls's Avatar
    Join Date
    Dec 2007
    Location
    Pakistan
    Posts
    262
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Use ajax man , this is the best way for calling php functions in javascript .

  6. #6
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    Is there a reason why the code has to be in PHP?
    If there is no database activity going on then there should be little reason why the PHP code can't be done in JavaScript as well.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •