Sean
|
Posted: 01/03/2002, 2:27 PM |
|
Hi All! Just a quicky...(i hope)!
I have a basic product table:
ID, Product, Description and Quantity.
I need to be able to Add and Subtract from the Quantity field. For example
just for testing, I've been trying to figure out how to make a field called
'Add 1' and when I click that, to have it add 1 to the Quantity field which
for testing is set to 5. So when I click 'Add 1', Quantity now is 6. Any
ideas? Thanks!
|
|
|
Nicole
|
Posted: 01/04/2002, 2:12 AM |
|
Sean,
the solution require some manual coding.
1. You should add button next to each field in grid form you want to increase. To do it add Label type field to the form and select 'HTML' checbox in its properties. Then add the code like below to BeforeShow event:
ASP
fldfield1 = "<form name = 'add1' method = POST action = 'AnyPage.asp'><input type = 'hidden' value='"&fldID&"' name='toadd_id'><input type=""submit"" value=""+1""></form>"
Now you have button next to each record.
2. to increase field value create and execute sql query in Open event of the same form:
ASP
if GetParam("toadd_id") <> "" then
sSQLu = "update table_name set quantity = quantity+1 where ID=" & GetParam("toadd_id")
cn.execute sSQLu
end if
Just in case PHP code:
1.
$fldfield1 = "<form name = 'add1' method = POST action = 'AnyPage.php'><input type = 'hidden' value='".$fldID."' name='toadd_id'><input type='submit' value='+1'></form>";
2.
if get_param("toadd_id") != ""
{
$sSQLu = "update table_name set quantity = quantity+1 where ID=" . get_param("toadd_id");
$db->query($sSQLu);
}
|
|
|
Alex Alexapolsky
|
Posted: 01/04/2002, 2:33 AM |
|
your button or link with Add 1 should point to a script or dummy CC page with
this code in Page/Open event :
cn.execute ("update mytable set field= myfield + 1 where id = " & GetParam("id"))
response.redirect "http://test.com/test.asp"
or
$db->query ("update mytable set field= myfield + 1 where id = " . get_param("id"));
header("Location: http://test.com/test.asp");
|
|
|
Sean
|
Posted: 01/04/2002, 11:07 AM |
|
I followed your example, however, when I hit the +1 button I receive this error:
[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'ID =' in the dummy page which has nothing except the Open event of:
cn.execute ("update Product set Quantity= Quantity + 1 where ID = " & GetParam("ID"))
response.redirect "Process.asp"
|
|
|
Sean
|
Posted: 01/04/2002, 11:13 AM |
|
Nevermind, I got it! Thanks so much guys!
|
|
|
Sean
|
Posted: 01/04/2002, 11:22 AM |
|
The adding of 1 works great, but I need to ultimitely need to have more buttons like +5,+10, -1,-5,-10 .... I can set the buttons up on the grid form, but am confused as far as the coding end..
|
|
|
Sean
|
Posted: 01/10/2002, 11:14 AM |
|
Everything is working great using all the above methods. Once I've updated the Quantity with the dummy page, it's returning the ProductGrid showing all table records...is there a way to have it just show the updated record instead of all of them? The working site is at http://12.224.4.170/inventory/ProductGrid.asp The search is searching ProductID which is just the product# in the table, the actual primary key is ID. And the dummy page that is doing the math has
cn.execute ("update Product set Quantity= Quantity+1 where ID = " & GetParam("toadd_id"))
response.redirect "ProductGrid.asp"
in the page/open event. Thanks!
|
|
|
Nicole
|
Posted: 01/11/2002, 1:44 AM |
|
Sean,
you should pass "ID" value to ProductGrid page. Add it as Input parameter for the Grid form. And modify the redirection code to get:
response.redirect "ProductGrid.asp?id=" & GetParam("toadd_id")
|
|
|
Sean
|
Posted: 01/11/2002, 3:05 PM |
|
Thanks Nicole, works like a charm!
|
|
|
Cc
|
Posted: 01/11/2003, 7:32 AM |
|
Try this.. Request.QueryString("T_Subtotal")
|
|
|