Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7

Thread: call

  1. #1
    New Coder
    Join Date
    Feb 2007
    Posts
    92
    Thanks
    1
    Thanked 0 Times in 0 Posts

    call

    i have a javascript function i want to call within my php script
    where should i place the javascript.

  • #2
    Regular Coder
    Join Date
    Oct 2005
    Location
    Right Here
    Posts
    654
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Anywhere you want before the call.

  • #3
    New Coder
    Join Date
    Feb 2007
    Posts
    92
    Thanks
    1
    Thanked 0 Times in 0 Posts
    it doesnt seem to recognise it when it's in the head tag.
    can it be within the php script?

  • #4
    Regular Coder
    Join Date
    Oct 2005
    Location
    Right Here
    Posts
    654
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Post up some code on what your trying to accomplish.

  • #5
    New Coder
    Join Date
    Feb 2007
    Posts
    92
    Thanks
    1
    Thanked 0 Times in 0 Posts
    thanks


    Code:
    <head>
    
    <script language="JavaScript">
    
    function UpdateQty(item)
    {
    itemId = item.name;
    newQty = item.options[item.selectedIndex].text;
    
    document.location.href = 'cart.php?action=update_item&id='+itemId+'&qty='+newQty;
    }
    
    </script>
    PHP Code:
    <?php
    .......
    echo 
    "<select name='" $row['Product_ID'] . "' onChange='" UpdateQty(this) . "'>";
    ....
    ?>

  • #6
    Regular Coder
    Join Date
    Oct 2005
    Location
    Right Here
    Posts
    654
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Your trying to make the javascript call a php call. Change to this

    PHP Code:
    <?php
    .......
    echo 
    "<select name='" $row['Product_ID'] . "' onChange='UpdateQty(this)'>";
    ....
    ?>

  • #7
    New Coder
    Join Date
    Feb 2007
    Posts
    92
    Thanks
    1
    Thanked 0 Times in 0 Posts
    ok thanks!


  •  

    Posting Permissions

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