Results 1 to 3 of 3

Thread: Sending var value from Add Value button

  1. #1
    Sencha User
    Join Date
    Jul 2011
    Posts
    49
    Vote Rating
    0
      0  

    Default Sending var value from Add Value button

    I have a table whose primary key is in varchar. I have form in extJS and process the inputted value on PHP file.

    In ExtJS grid, I have to set some values to differentiate whether the form is for Add value (new data) or Edit value (update data). I've tried the value (var actiontype) to send to PHP file when I clicked the Add Value button. Here is the code for tbar in js file:

    Code:
    tbar: [
                {
                text:'Add Value',
                icon: 'img/table_add.png',
                scope:this,
                handler:function(){
                    var getFormWindow = new applabel_TypeSiteFormWindow(applabel_store);
                    var actiontype = 1;
                    getFormWindow.getFormPanel().getForm().reset();
                    getFormWindow.show();
                }
            },
    And here is the PHP code:

    Code:
    $field_value = array(
                        "id_one"=>$_POST["id_one"], //id_one is in varchar data type
                        "id_two"=>$_POST["id_two"],
                        "txt"=>$_POST["txt"]
                    );
                
    if($_GET["actiontype"]==1){                
                    $db->insert("tb_label", $field_value);   
                }else if ($_POST["actiontype"]==2){                
                    $db->update("tb_label", $field_value,"id_one = '".$_POST["id_one"]."' and id_two = '".$_POST["id_two"]."'");                
                                }

    I got Successfully saved alert message, but somehow the data aren't added into database.

    Any solution how to fix that? Thanks in advance.

  2. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,556
    Vote Rating
    1272
      0  

    Default

    Where do you send the request in relation to the button handler?
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

  3. #3
    Sencha User
    Join Date
    Jul 2011
    Posts
    49
    Vote Rating
    0
      0  

    Default [SOLVED] Add xtype hidden to form

    Thanks for your reply, mitchell.

    It was just solved.

    It turns out I only have to add xtype hidden (e.g. name: action) and set the value (e.g. 'edit' or '1') on form panel (in js file). Furthermore, I have to create if-else condition on PHP file considering the hidden field.

    IF ($_POST["actiontype"]=='1') { edit/update process } ELSE{ add/create process }.

    By using the hidden field, the set value only send to rowclick action (edit/update process), not to create new (Add value) data.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •