FAQ
Hello guys,

I am trying to set the 'value' of a select using the cake 2.x
JsHelper, but unlucky so far.

I`ve managed to change all options of the select, but I have no clue
on how to change only the 'value'.

I have 2 selects with constant options (the options doesn`t change).
I want to set the 'value' of the second select, depending on the
'value' of the first select.

Does anyone here knows how to do this?

Thanks.

--
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

Search Discussions

  • Renato Carvalho at Jun 20, 2012 at 6:46 pm
    I still haven't made any progress, any suggestions?

    I have two selects, like that:

    echo $this->Form->select('myFieldInFirstSelect',
    $myOptionsInFirstSelect);
    echo $this->Form->select('myFieldInSecondSelect',
    $myOptionsInSecondSelect, array('value' => $myValueInSecondSelect));

    And I am trying something like:

    $this->Js->get('#myFirstSelectId')->event('change',
    $this->Js->request(array(
    'controller'=>'myCustomController',
    'action'=>'myUpdateSelectFunctionWithoutView'
    ), array(
    'update'=>'#mySecondSelectId',
    'async' => true,
    'method' => 'post',
    'dataExpression'=>true,
    'data'=> $this->Js->serializeForm(array(
    'isForm' => true,
    'inline' => true
    ))
    ))
    );

    And in myUpdateSelectFunctionWithoutView, I do:

    function myUpdateSelectFunctionWithoutView {
    $this->set('myValueInSecondSelect', array('1' => 'option 1'));
    }


    Any help??
    On 18 jun, 03:32, Renato Carvalho wrote:
    Hello guys,

    I am trying to set the 'value' of a select using the cake 2.x
    JsHelper, but unlucky so far.

    I`ve managed to change all options of the select, but I have no clue
    on how to change only the 'value'.

    I have 2 selects with constant options (the options doesn`t change).
    I want to set the 'value' of the second select, depending on the
    'value' of the first select.

    Does anyone here knows how to do this?

    Thanks.
    --
    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
  • Борислав Събев at Jun 21, 2012 at 4:52 am
    Well I personally do not use JsHelper as I prefer clean JavaScript but
    after reading this tutorial form the CakePHP Book<http://book.cakephp.org/2.0/en/core-libraries/helpers/js.html>the answer would be:

    <?php$this->Js->get('#select1')->event('change', $eventCode);
    ?>

    Where $eventCode should change the value of #select2.


    With some clean jQuery code the answer will be:

    $(document).ready(function() {

    $('#select1').change(function(){
    $('#select2').val(NEWVALUEHERE);
    });

    });


    On Monday, 18 June 2012 09:32:04 UTC+3, Renato Carvalho wrote:

    Hello guys,

    I am trying to set the 'value' of a select using the cake 2.x
    JsHelper, but unlucky so far.

    I`ve managed to change all options of the select, but I have no clue
    on how to change only the 'value'.

    I have 2 selects with constant options (the options doesn`t change).
    I want to set the 'value' of the second select, depending on the
    'value' of the first select.

    Does anyone here knows how to do this?

    Thanks.
    On Monday, 18 June 2012 09:32:04 UTC+3, Renato Carvalho wrote:

    Hello guys,

    I am trying to set the 'value' of a select using the cake 2.x
    JsHelper, but unlucky so far.

    I`ve managed to change all options of the select, but I have no clue
    on how to change only the 'value'.

    I have 2 selects with constant options (the options doesn`t change).
    I want to set the 'value' of the second select, depending on the
    'value' of the first select.

    Does anyone here knows how to do this?

    Thanks.
    --
    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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupcake-php @
categoriesphp
postedJun 18, '12 at 9:12a
activeJun 21, '12 at 4:52a
posts3
users2
websitecakephp.org
irc#cakephp

People

Translate

site design / logo © 2022 Grokbase