Results 1 to 4 of 4

Thread: Do javascript using PHP

  1. #1
    Join Date
    Sep 2013

    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>
    a javascript page:

    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
    1 - var quantity_in_stock_S
    when removeWS is clicked:

    PHP Code:

    fwrite(...); /* 1 - quantity_in_stock_S*/
    That kind of idea...

  2. #2
    Join Date
    Jul 2013
    Voorheesville NY USA

  3. #3
    Join Date
    Apr 2012
    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:

    <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']?>
    In the PHP you should update the value in the database to the new value.

  4. #4
    Join Date
    Mar 2007
    Suggest you use AJAX to make a query to a PHP script that then reads the file/database and returns the data requested.
    Yes, I know I'm about as subtle as being hit by a bus..(\\.\ Aug08)
    Yep... I say it like I see it, even if it is like a baseball bat in the nutz... (\\.\ Aug08)
    I want to leave this world the same way I came into it, Screaming, Incontinent & No memory!
    I laughed that hard I burst my colostomy bag... (\\.\ May03)
    Life for some is like a car accident... Mine is like a motorway pile up...

    Problems with Vista? :: Getting Cryptic wid it. :: The 'C' word! :: Whois?

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