Monday, October 3, 2011

Re: jquery: passing value from option select element

miracles do happen!!

turned out my code was correct. i just did not changed the value of
the box when i tested. i missed that it named "change" for a reason...

good god....

anyway...this one may be closed...have a nice evening all ;)

On 3 Okt., 17:00, Tomfox Wiranata <tomfox.wiran...@gmail.com> wrote:
> hi everyone,
>
> can't get my mind to understand that. this is what i do:
>
> I read data from my database and echo it. one value is a status of a
> dataset. I write this status in an option value:
>
> <select class="reported_'.$reportedUser['Report']['id'].'" size="1"
> style="width: 98%;margin-top: 5px;">
>         <option value="">'.$reportedUser['Report']['status'].'</option>
>         <option value="pending">pending</option>
>         <option value="locked">locked</option>
>         <option value="closed">closed</option>
>     </select>
>
>     </div>';
>
>         echo '<div id="reported_'.$reportedUser['Report']['id'].'"
> onclick="saveStatus('.$reportedUser['Report']['id'].')" </div>';
>
> now what i wanna do: when the admin changes the value from "new" to
> "locked" and presses the div, the new value is passed (together with
> the "id") to a jquery function:
>
> function saveStatus(id)
> {
>         var reportedDiv = '#reported_';
>         var optionValue = $(reportedDiv + id).text();
>
>         if(id != '')
>         {
>
>                         alert(optionValue);
>                         alert(id);
>         };
>
> }
>
> I successfully pass the id to the function. the acutal value of the
> option field not so much!!!
>
> I appreciate the help :)

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


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

No comments: