CodeCharge Studio
search Register Login  

Visual Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 [SOLVED] Get listbox value in editable grid - seperate from row data

Print topic Send  topic

Author Message
Zye

Posts: 56
Posted: 06/17/2009, 2:43 PM

I have a listbox in an editable grid populated from a seperate table in the database (shipping_id, shipping_name, shipping_price). The listbox is seperate from the editable grid row data.
I need to get the value of the listbox selection so that I can add the shipping price to a total price. I also need to retain the selected listbox option (may need to create a seperate db table or session to retain it). The grid is submitted. I have been reading the forums for the last three days and I am no closer to a solution. I have tried coding the listbox but I am not sure how to formulate it. In beforeshow of "ship_list" label I put the following experimental code which works except for the "selected" bit which I need the listbox value for. I cannot get the value of the listbox.

  
$db2 = new clsDBconnection();  
$ship_select = isset($_GET['shipping']);  
//$ship_select = $_POST['shipping'];  
  
if ($ship_select == "") {  
$selected = "SELECTED";  
} else {  
$selected = "";  
}  
$SQL2 = "SELECT shipping_id, concat_ws(' - £',shipping_name,shipping_price) as shipping_name FROM shipping ORDER BY shipping_id";  
$db2->query($SQL2);  
$SizeListbox = "<SELECT NAME=\"shipping\" onchange=\"this.form.submit()\"><OPTION value=\"\" " . $selected . ">Select Shipping</OPTION>";  
while($db2->next_record()) {  
$SizeListbox = $SizeListbox . "<OPTION value=\"" . $db2->f("shipping_id") . "\" " . $selected . ">" . $db2->f("shipping_name") . "</OPTION>";  
}  
$SizeListbox = $SizeListbox . "</SELECT>";  
$db2->close();  
$shop_cart->ship_list->SetValue($SizeListbox);

Has anyone had a similar problem or can you point me in the right direction? I read that Saseow had a similar problem but I can't find the post and the solution was not given. Please help me.

PHP 5, MySQL 5, CCS 4.2.00.040, XP Pro
View profile  Send private message
jjrjr1


Posts: 942
Posted: 06/17/2009, 10:17 PM

Hi

Have not seen you around in a while.

How are you these days?

Let me think about this one.

John
_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
View profile  Send private message
jjrjr1


Posts: 942
Posted: 06/17/2009, 10:24 PM

Question

Does each row in an editable grid have this list box???

How exactly does the listbox affect the edit of that row?


_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
View profile  Send private message
jjrjr1


Posts: 942
Posted: 06/17/2009, 10:46 PM

Can you sort of flow chart how you want this to work?

_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
View profile  Send private message
Zye

Posts: 56
Posted: 06/18/2009, 6:13 AM

Hi John

Thanks for looking in. I posted this thread late last night Zzzzz!! (UK time). Late rise today. I have been lurking here and CCSElite in between times. I have been very busy juggling things for quite a few months, since project spending uptake has been slow for business. Soldiering on still. Respect for all the work you and Rick have done for the community. You have some cool apps happening. Hope things are going well for you both.

The listbox is outside the editable grid row. It is just used to add a shipping choice to the overall total price which is presently being calculated in beforeshow of the e-grid (shop_cart). I need to retain the listbox selection through a couple of pages until the overall total is sent to the payment gateway. The grid is using custom update and delete.

In beforeshow of the editable grid - Based on CCS cart example

  
$db = new clsDBconnection();  
  
  // Count Order Total  
  $SQL = "SELECT SUM(price*quantity) as total "   
        ."FROM store_shopping_cart_items a, store_products b "   
        ."WHERE a.product_id=b.product_id AND "   
 	    ."shopping_cart_id =" . $db->ToSQL(CCGetCookie("shopping_cart_id"),ccsInteger);  
  $db->query($SQL);  
  if($db->next_record()) {  
     $OrderTotal = $db->f("total");  
}  
  
// $shiptotal = CCGetSession("shipping");   
// Maybe I could save the listbox value as a session and use it to lookup the price or get the price from a CCDLookUp if I can get the selected listbox value saved to a db table.  
  
// $shiptotal = CCDLookUp("shipping_price", "shipping_sel", "shipping_id=" . CCToSQL(CCGetSession("shipping"), ccsInteger), $db);  
  
$shop_cart->total->SetValue($OrderTotal + $shiptotal);  
  
$db->close();  

Cheers ... hope it makes sense. :-/ Still thinking ...
View profile  Send private message
Zye

Posts: 56
Posted: 06/18/2009, 6:35 AM



The e-grid rows are filled with the products etc. Everything works except for shipping ...
View profile  Send private message
jjrjr1


Posts: 942
Posted: 06/18/2009, 8:56 AM

Hi Zye

Good to hear all is well with you.

I think you are on the right track to use a session variable.

The issue is where you set it I think.

If you set a session variable for the listbox in the on-validate event. I think you will find you can
get that session variable in the before show event to add to your calculation and also set the listbox with the session variable before show.

I don't know if your page calculates the total for desplay before submit. But if you want it to do that just create custom client side code to do the math in the on change event for the control

Let me know if that helps

John
_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
View profile  Send private message
jjrjr1


Posts: 942
Posted: 06/18/2009, 8:58 AM

Oh and by the way.

Forgot this piece.

Create a hidden field on the page where you can do a Dlookup for the shipping price and put that value in the hidden control for your math on the page.


_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
View profile  Send private message
Zye

Posts: 56
Posted: 06/18/2009, 4:55 PM

You are the man John. Many thanks for pointing me in the right direction. Just what I needed.

  
// OnValidate - e-grid  
$ship_list = CCGetParam("shipping",""); // Get listbox param  
CCSetSession("shipping", $ship_list); // set session  
$shop_cart->ship->SetValue($ship_list); // set value hidden field - not really needed in this case  
  
// BeforeShow  
$db = new clsDBconnection();  
$shop_cart->ship->SetValue(CCGetSession("shipping")); // testing  
$shop_cart->shipping->SetValue(CCGetSession("shipping")); // set listbox value  
$shippingprice = CCDLookUp("shipping_price", "shipping", "shipping_id=" . CCToSQL(CCGetSession("shipping",""), ccsInteger), $db); // get shipping price  
$shop_cart->total->SetValue($OrderTotal + $shippingprice); // add price to total  
$db->close();  

All the best - I will have to get my card out at CCSElite when it is topped up 8-)

Zye ...
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

PHP Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.