Jump to content

A simple problem


riddhi

Recommended Posts

The problem for mr is that I want the processing to take place after the user clicks add to cart button

 

echo "<br /><br />";
echo " <div align='right'> ";
echo "<form name='form1' method='get' action='cart.php?action=view'>";
echo "<input name='cart' type='submit' value='Add To Cart' />";
echo "</form>";

 

  That is I wish to perform the following steps after add to cart button is pressed:-

  echo "<form name='form1' method='get' action='cart.php?action=view'>";

  // and also perform some more processing

Link to comment
https://forums.phpfreaks.com/topic/48054-a-simple-problem/
Share on other sites

write a function and call it onSubmit

 


echo "<script='text/javascript'>";
echo "function doStuff()";
echo "{";
//write what you want processing in here, javascript code obviously
echo "}";
echo "</script>";

//then have this

echo "<form name='form1' method='get' action='cart.php?action=view' onSubmit="doStuff()">";
echo "<input name='cart' type='submit' value='Add To Cart' />";

Link to comment
https://forums.phpfreaks.com/topic/48054-a-simple-problem/#findComment-234868
Share on other sites

Thank you  paul2463  for the help. However, I am new to java script:-

 

Please help with the code written in php and convert it into java script:-

 

where $productId[] is an array

 

function process(){

  {

    global $productId[];

 

    echo "<script='text/javascript'>";

    echo "function doStuff()";

    echo "{";

// I want to traverse the productId[] array

        // and assign like this:-

        //$_GET['p']=$record['PD_ID'];

      //and call the php

      // function addToCart();

 

//write what you want processing in here, javascript code obviously

    echo "}";

    echo "</script>";

Link to comment
https://forums.phpfreaks.com/topic/48054-a-simple-problem/#findComment-235075
Share on other sites

I am lost as to what you want , do you want a function that processes more data "before it is POSTed to another page(or back to itself), do wish it in PHP which means the data has to go away and come back to be acted upon, or do you wish it to be acted on client side before being sent away???

 

exactly what do you want to happen and when do you want it to happen?

Link to comment
https://forums.phpfreaks.com/topic/48054-a-simple-problem/#findComment-235104
Share on other sites

Ok here you go.

 

This is an online shopping application I want the customer to Search for the product and add those product to the cart only when the customer clicks "Checkout button.

 

      As I am storing the product id as they are generated in the array $productID[]. I am next calling another page cart.php which contain the cart application and uses the get method (where I add those product id).

  And finally call the function addToCart() to add to the database.

        I hope that makes things clear if not I am waiting for more questions.

 

Link to comment
https://forums.phpfreaks.com/topic/48054-a-simple-problem/#findComment-235423
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.