Results 1 to 3 of 3

Thread: Changing or adding elements to a form dynamically

  1. #1
    Sencha User
    Join Date
    Aug 2010
    Posts
    30

    Default Changing or adding elements to a form dynamically

    I'm trying to figure out how to change extjs code of movie-form below on the fly using some javascript -- like add a menu item or button to a form dynamically. I was hoping to just access the extjs element then use some ext core functions to change things.

    Problem 1: The movie-form form shows properly until I add the ext-core.js package then it disappears. I get no error in the firefox console though...I read that the ext-core packages are necessary to change values or alter elements in the example below. What am I doing wrong?

    Problem 2: Can someone post an example of adding something to movie-form or changing a value in movie-form. I can't seem to get either of these to work.

    Thanks,

    Dan

    Code:
    <html>
    
    <head>
    <link rel="stylesheet" type="text/css" href="resources/css/ext-all.css" />
    <script type="text/javascript" src="adapter/ext/ext-base.js"></script>
    <script type="text/javascript" src="ext-all.js"></script>
    <script type="text/javascript" src="pkgs/ext-core.js"></script>
    
    </head>
    <body>
    
    <div id="joe"></div>
    
    </body>
    </html>
    
    
    <script>
    //javascript:alert(Ext.get(movie_form))
    Ext.onReady(function(){
    var movie_form = new Ext.FormPanel({
    url: 'movie-form-submit.php',
    renderTo: joe,
    frame: true,
    title: 'Movie Information Form',
    width: 250,
    items: [{
    xtype: 'textfield',
    fieldLabel: 'Title',
    name: 'title'
    },{
    xtype: 'textfield',
    fieldLabel: 'Director',
    name: 'director'
    },{
    xtype: 'datefield',
    fieldLabel: 'Released',
    name: 'released'
    }]
    });
    });
    </script>

  2. #2
    Sencha Premium User danguba's Avatar
    Join Date
    Feb 2009
    Location
    Kragujevac, Serbia
    Posts
    434

    Default

    If U R including ext-all.js U don't need to include ext-core since it is already in ext-all.

    to add field to a form just use add method (http://dev.sencha.com/deploy/dev/doc...ner&member=add)

    Code:
    movie_form.add({
        xtype: 'textfield',
        fieldLabel: 'New Field'
    });
    movie_form.doLayout();
    All Best
    ---
    Željko Mitrović
    http://skitanja.blogspot.com/

    "Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." Martin Golding

  3. #3
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    To clarify: ext-core is a free library that is build up from ext-base and parts of ext-all, so if you include both ext-base and ext-all then you don't need ext-core.

Similar Threads

  1. How to add form elements dynamically
    By icarey in forum Ext 3.x: Help & Discussion
    Replies: 1
    Last Post: 19 Aug 2010, 2:47 AM
  2. Changing the label of form elements in Form Layout
    By s.m.srinivas in forum Ext 3.x: Help & Discussion
    Replies: 1
    Last Post: 9 Sep 2009, 10:58 AM
  3. Adding and Removing Accordion Elements Dynamically
    By ogradyjd in forum Ext 2.x: Help & Discussion
    Replies: 16
    Last Post: 12 Dec 2008, 8:59 AM
  4. Can wee add form elements dynamically to a Panel.
    By rudy23 in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 2 Jul 2008, 8:01 AM
  5. Dynamically changing (form) labels
    By reinouts in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 26 May 2008, 12:52 AM

Posting Permissions

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