Wrox Programmer Forums
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old March 5th, 2006, 12:04 AM
Registered User
Join Date: Mar 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default input form ( onclick)

the input button i cannot go the the add_to_cart.php. is it the problem the form dunno the button is refer to which record ? since i retrieve from database. how can i know that, the which button is refer to which record(which row) and send the id to the next page ?

for ($i=0; $i < $num_result; $i++){
          $row = mysql_fetch_array($result);
          $id = $row["product_id"];

          echo "<tr bgcolor=#ffcc99><td>";
          echo "<a href=" .$row["product_id"]." target=_blank />";
          echo $row["product_desc"];
          echo "</a></td><td>";;
          echo $row["price"];
          echo "</td><td>";

          echo "<FORM NAME=order>";

          echo "<input type="button" value="Add to Cart" onclick="document.location='add_to_cart.php';">";
          echo "</br>";
         echo "Quantity: <input type=text size=2 maxlength=3 name=QUANTITY value='1'>";

         echo "<p>";
         echo "<input type=hidden name=PRICE value=".$row["price"].">";
         echo "<input type=hidden name=PRODUCT_DESC value=".$row["product_desc"].">";
         echo "<input type=hidden name=ITEM_ID value=".$row["product_id"].">";
         echo "<a href=\"123.php\">Check out</a></p>";
         echo "</FORM></td></tr>";

Old March 6th, 2006, 01:48 AM
Friend of Wrox
Join Date: Oct 2004
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to vinod_yadav1919 Send a message via Yahoo to vinod_yadav1919

Hii bubblegirl!!

use document.location.href='add_to_cart.php'
since you want to post some values of form i.e price,item id ,so put it in form action tag.
i.e. action='add_to_cart.php'
again either add handler to "Add to Cart button" or use javascript code for posting the form.
hope this will help you.
since this query is also related to PHP ,u can post ur code in PHP forum also.

hope this will help you

Cheers :)


Similar Threads
Thread Thread Starter Forum Replies Last Post
change the form input value maggiefeng Classic ASP Basics 2 December 10th, 2006 10:28 AM
Adding onclick stuff to an INPUT via javascript p.ross BOOK: Professional JavaScript for Web Developers ISBN: 978-0-7645-7908-0 1 November 29th, 2005 01:08 PM
radio button onClick submit form crmpicco HTML Code Clinic 1 June 14th, 2005 08:32 AM
submitting a form have an input File alyeng2000 Classic ASP Basics 6 November 1st, 2003 09:22 PM
form input as database name gtmm9 Classic ASP Databases 1 October 21st, 2003 03:12 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.