Wednesday, December 29, 2010

Re: using <select> onmouseup to update database

Hi,

The code doesn't seem to be as per CakePHP standard. However, you need to handle onchange event of a select to save the selected option (probably using an AJAX request).

Amit Badkas

PHP Applications for E-Biz: http://www.sanisoft.com



On Thu, Dec 30, 2010 at 12:58 AM, roundrightfarm <roundrightfarm@gmail.com> wrote:
I have a <select><option> drop down menu in a view and I'm wondering
if i can send data based on the selected result to my database when it
is selected onmouseup.

the <option>s are populated from the optional_share_products table.
I'd like to send data about the selected product (actually Item.id) to
the optional_share_users table to record the choice for that user.

this is what I have so far

[code]<div id="shares">
 <? foreach ($optional_shares as $optional_share){
   foreach($share_users as $user){
    if ($user['OptionalShareUser']['user_id'] == $this->Session-
>read('Auth.User.id') && $user['OptionalShareUser']['share_id'] ==
$optional_share['OptionalShare']['id']){
     echo ('<p>Your ' . $optional_share['OptionalShare']['name'] . '
share this week is');?>

     <select ">
      <? foreach ($share_products as $product){
           if ($optional_share['OptionalShare']['id'] ==
$product['OptionalShareProduct']['share_id']){
         echo ('<option> '. $product['Item']['name'] . '</option>');
           }
          } ?>
     </select>
      <? }
         else continue;
        }
   }?></p>
 </div>[/code]

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
 
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

No comments: