Jump to:

2011 Posts in 1436 Topics by 620 members

Form Questions

SilverStripe Forums » Form Questions » event onchange 2 Dropdown

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 1247 Views
  • majo
    Community Member
    2 Posts

    event onchange 2 Dropdown Link to this post

    Hello, I need to understand how to work with events in SilverStripe. Example:
    For simplicity, I have 2 dropdown A and B. The need to respond to the OnChange And so I choose and obtain the data in b. Using jQuery I can catch OnChange event see code.

    (function($) {
    $("#MyForm_mujForm_ulice").change(function () {
    $("#MyForm_mujForm_ulice option:selected").each(function () {
    //Now what?

    Now I do not know how to call a function, who have in my control.

    function onchange($request) {
    $pol = array(1=>1,2=>2);

    FormResponse::update_dom_id('MyForm_test', 'test');
    FormResponse::status_message('Done', 'good');

    return FormResponse::respond();

    I modified the controller:

    public function index(){
    if(Director::is_ajax() == false){
    return array();
    $data = array( 'Test' => 'value');
    return json_encode($data);


    Ajax calls a function:

    $("#lab").load('My_Controller', function(vystup){
    alert("echo: " + vystup.test);

    Unfortunately I can not get the value of the test. pops up in my error alert:
    echo: undefined

    A solution is parsed!!!!!!!
    var obj = jQuery.parseJSON(vystup);

    P.S. Sorry for my English.

Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.