Gelmiş geçmiş en büyük porno sitemiz olan 2pe de her zaman en kaliteli pornoları sunmayı hedefledik. Diğer video sitemiz olan vuam da ise hd porno ağırlıklı çalışmalara başladık.

  1. #1
    Sencha User
    Join Date
    May 2011
    Posts
    21
    Vote Rating
    1
    ajg3 is on a distinguished road

      0  

    Default Setting current date in a form

    Setting current date in a form


    Relatively new here. I have looked through examples and have only seen stuff with a date picker but I am not looking for that. I am currently setting up a form but can't seem to get this part of it.


    I have declared variables for the date as well.

    var date = new Date();
    var d = date.getDate();
    var m = date.getMonth();
    var y = date.getFullYear();

    I would like for the date field to be automatically populated with the current date and be locked. Any idea's?

    Code:
    items: [
            {
            xtype: 'fieldset',
            title: 'Details',
            items: [{
                xtype: 'textfield',
                name : 'fname',
                label: 'First Name',
    			required: true
                },{
                xtype: 'textfield',
                name : 'lname',
                label: 'Last Name',
    			required: true
                },{
                xtype: 'textfield',
                name : 'pnumber',
                label: 'Phone Number',
    			required: true
                },{
                xtype: 'textfield',
                name : 'date',
                label: 'Date',
                }
    ]
    }]

  2. #2
    Sencha - Services Team AndreaCammarata's Avatar
    Join Date
    Jun 2009
    Posts
    1,394
    Vote Rating
    22
    AndreaCammarata has a spectacular aura about AndreaCammarata has a spectacular aura about

      1  

    Default


    Hi ajg3.
    I suggest you to add two function to your application:

    1. Function able to retrive the data in the right format
    Code:
    function getDate(){
        var currentTime = new Date();
        var month = addZero(currentTime.getMonth() + 1);
        var day = addZero(currentTime.getDate());
        var year = currentTime.getFullYear();
        return(day + "/" + month + "/" + year);
    }
    2. Support function to add zero to properly format the numbers
    Code:
    function addZero(num)
    {
        (String(num).length < 2) ? num = String("0" + num) :  num = String(num);
        return num;        
    }
    Then edit your application code in this way:

    Code:
    items: [{
        xtype: 'fieldset',
        title: 'Details',
        items: [{
            xtype: 'textfield',
            name : 'fname',
            label: 'First Name',
            required: true
        },{
            xtype: 'textfield',
            name : 'lname',
            label: 'Last Name',
            required: true
        },{
            xtype: 'textfield',
            name : 'pnumber',
            label: 'Phone Number',
            required: true
        },{
            xtype: 'textfield',
            name : 'date',
            label: 'Date',
            value: getDate()
        }]
    }]
    Hope this Helps.
    Sencha Inc
    Andrea Cammarata, Solutions Engineer
    CEO at SIMACS

    @AndreaCammarata
    www.andreacammarata.com
    github: https://github.com/AndreaCammarata

    TUX components bundle for Sencha Touch 2.x.x
    http://www.tux-components.com/


  3. #3
    Sencha User
    Join Date
    May 2011
    Posts
    21
    Vote Rating
    1
    ajg3 is on a distinguished road

      1  

    Default


    Thanks for the response! I am having another issue though. I have been going through all the Intro videos and piecing my app together that way, since I am new to this. So i have the Viewport thing going. There is the app.js which launchs the Viewport.js. And from this Viewport i have my tabPanel and items with xtypes to a seperate card.

    Here is my code of one of the cards where i want to call the function:

    Code:
    ToolbarDemo.views.Testcard = Ext.extend(Ext.form.FormPanel, {
    	
    	scroll: 'vertical',
    	id: 'hform',
    	
    	items: [
            {
            xtype: 'fieldset',
            title: 'Details',
    		
    		defaults: {
    			labelWidth: '35%'
    		},
            items: [{
                xtype: 'textfield',
                name : 'fname',
                label: 'First Name',
    			required: true
                },{
                xtype: 'textfield',
                name : 'lname',
                label: 'Last Name',
    	    required: true
                },{
                xtype: 'textfield',
                name : 'pnumber',
                label: 'Phone Number',
    	    required: true
                },{
                xtype: 'textfield',
                name : 'date',
                label: 'Date'
                }],
    		},{
    			layout: 'vbox',
    			defaults: {xtype: 'button', flex: 1, style: 'margin: .5em;'},
    			items: [{
           			text: 'Clear',
    				scope: this,
    				handler: function(){
    					Ext.getCmp('hform').reset();
    				}
            	},{
    				xtype: 'button',
    				text: 'Submit'
    				}
    			],
    		},]
    });
    
    Ext.reg('testcard', ToolbarDemo.views.Testcard);
    I am confused as to where i can put this function...i notice the handler function with the Clear button as far as adding a function there but no dice.

    any help would be appreciated...and should i avoid using the Viewport style and instead create variables as panels?
    Last edited by ajg3; 6 May 2011 at 12:44 PM. Reason: spelling

  4. #4
    Sencha User
    Join Date
    Oct 2013
    Posts
    2
    Vote Rating
    0
    ikhanrahi is on a distinguished road

      0  

    Default


    Thanks man. it works

Similar Threads

  1. Get current date
    By pokiekokie in forum Sencha Touch 1.x: Discussion
    Replies: 1
    Last Post: 22 Jan 2012, 9:21 PM
  2. How can select current day date and future day date only ?
    By Sandeep in forum Sencha Touch 1.x: Discussion
    Replies: 1
    Last Post: 9 Jan 2011, 10:56 AM
  3. problem with getting current date and time
    By ghatfan99 in forum Ext GWT: Discussion
    Replies: 4
    Last Post: 2 Aug 2010, 3:38 AM
  4. How can select future day date only not a past date and current date
    By painter in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 6 Apr 2009, 10:11 PM
  5. How can select current day date and future day date only
    By painter in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 6 Apr 2009, 6:21 AM

Thread Participants: 2