dcsimg
www.webdeveloper.com
Results 1 to 4 of 4

Thread: Do javascript using PHP

  1. #1
    Join Date
    Sep 2013
    Posts
    12

    Talking Do javascript using PHP

    I have a html page:

    HTML Code:
    <form action="stock.php" method="post">
    S:<input value="remove" name="removeWS" type="submit" /> </br>
    M:<input value="remove" name="removeWM" type="submit" /> </br>
    L:<input value="remove" name="removeWL" type="submit" /> </br>
    </form>
    a javascript page:

    Code:
    var quantity_in_stock_S = 2
    var quantity_in_stock_M = 2
    var quantity_in_stock_L = 1
    I am wanting a php page to make do
    Code:
    1 - var quantity_in_stock_S
    when removeWS is clicked:

    PHP Code:
    <?php

        $f 
    fopen("1stock.js""a+");
            
    fwrite(...); /* 1 - quantity_in_stock_S*/
    That kind of idea...

  2. #2
    Join Date
    Jul 2013
    Location
    Voorheesville NY USA
    Posts
    956
    ???

  3. #3
    Join Date
    Apr 2012
    Posts
    38
    Why don't you save the value in the database and fill in the javascript on basis of the database value?
    Declare the variables in the HTML page, insert some PHP where you pull the data from the database.
    The javascript part in your HTML could be like this:

    Code:
    <script type="text/javascript">
    var quantity_in_stock_S = <?=$row['quantity_s']?>
    var quantity_in_stock_M = <?=$row['quantity_m']?>
    var quantity_in_stock_L = <?=$row['quantity_l']?>
    </script>
    In the PHP you should update the value in the database to the new value.

  4. #4
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,589
    Suggest you use AJAX to make a query to a PHP script that then reads the file/database and returns the data requested.
    If your post falls off the page, bump it. ...
    Please remember to wrap any code you have in forum tags:-

    [CODE]...[/CODE] [HTML]...[/HTML] [PHP]...[/PHP]

    If you can't think outside the box, you will be trapped forever with no escape...

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles