PDA

View Full Version : Form after submit...



mave
13 Aug 2009, 10:34 AM
Hey guys... got a little problem... i have a form that will open in a window after clicking a button... than the user can put some stuff in the fields... validation is fine... but now to the problem...

after pressing the submit button it went on to the php site which takes the data was set... but i want that after clicking submit the same window should stay and a little msg like "your request was sent" or "failed" is inside... how can i do that???

would be great if someone could help...

evant
13 Aug 2009, 10:37 AM
Ext.onReady(function(){

Ext.BLANK_IMAGE_URL = 'ext/resources/images/default/s.gif';

Ext.QuickTips.init();
Ext.form.Field.prototype.msgTarget = 'side';

var win;
var button = Ext.get('show_window');

var myForm = new Ext.FormPanel
({
labelWidth: 75,
standardSubmit: true,
'php/myform.php',
frame:true,
title: 'Bitte geben Sie Ihre Adressdaten ein:',
bodyStyle:'padding:5px 5px 0',
width: 400,
defaults: {width: 230},
defaultType: 'textfield',
items:
[{
fieldLabel: 'Apotheke',
name: 'apotheke',
allowBlank: false
},{
xtype: 'combo',
displayField:'state',
name: 'salutation',
store: ['Frau', 'Herr'],
typeAhead: true,
mode: 'local',
forceSelection: true,
triggerAction: 'all',
emptyText:'Please select...',
selectOnFocus:true,
allowBlank:false
},{
fieldLabel: 'Vorname',
name: 'vorname',
allowBlank:false
},{
fieldLabel: 'Nachname',
name: 'nachname',
allowBlank:false
},{
fieldLabel: 'Strasse',
name: 'strasse',
allowBlank:false
},{
fieldLabel: 'PLZ',
name: 'plz',
width: 50,
maxLength: 5,
allowBlank:false
},{
fieldLabel: 'Ort',
name: 'ort',
allowBlank:false
},{
fieldLabel: 'E-Mail',
name: 'email',
vtype:'email',
allowBlank:false
},{
hidden: true
},{
hideLabel: true,
boxLabel: 'Ich akzeptiere die <a href="http://" target="_blank">Link</a>.',
xtype: 'checkbox',
name: 'checkbox',
width: 340,
allowBlank:false
}],
buttons:
[{
text: 'Senden',
handler: function()
{
myForm.getForm().submit({
success: function(){
alert('done');
}
});
}
},{
text: 'Abbrechen',
handler: function()
{
win.hide();
}
}]
});

button.on('click', function()
{
if(!win)
{
win = new Ext.Window
({
applyTo:'window',
layout:'fit',
width:370,
height:370,
closeAction:'hide',
resizable:false,
plain: true,
closable:false,
items: [myForm]
});
}
win.show(this);
});
});

mave
13 Aug 2009, 10:51 AM
thx for the fast reply! i changed it to this:

the problem is after submitting it... it just reloads the full page... is that right? i thought it stays in the same window just with the msg done... whats wrong? :(

evant
13 Aug 2009, 11:04 AM
You can read the documentation, lots of useful stuff in there.



Ext.onReady(function(){

Ext.BLANK_IMAGE_URL = 'ext/resources/images/default/s.gif';

Ext.QuickTips.init();
Ext.form.Field.prototype.msgTarget = 'side';

var win;
var button = Ext.get('show_window');

var myForm = new Ext.FormPanel
({
labelWidth: 75,
url: 'php/myform.php',
frame:true,
title: 'Bitte geben Sie Ihre Adressdaten ein:',
bodyStyle:'padding:5px 5px 0',
width: 400,
defaults: {width: 230},
defaultType: 'textfield',
items:
[{
fieldLabel: 'Apotheke',
name: 'apotheke',
allowBlank: false
},{
xtype: 'combo',
displayField:'state',
name: 'salutation',
store: ['Frau', 'Herr'],
typeAhead: true,
mode: 'local',
forceSelection: true,
triggerAction: 'all',
emptyText:'Please select...',
selectOnFocus:true,
allowBlank:false
},{
fieldLabel: 'Vorname',
name: 'vorname',
allowBlank:false
},{
fieldLabel: 'Nachname',
name: 'nachname',
allowBlank:false
},{
fieldLabel: 'Strasse',
name: 'strasse',
allowBlank:false
},{
fieldLabel: 'PLZ',
name: 'plz',
width: 50,
maxLength: 5,
allowBlank:false
},{
fieldLabel: 'Ort',
name: 'ort',
allowBlank:false
},{
fieldLabel: 'E-Mail',
name: 'email',
vtype:'email',
allowBlank:false
},{
hidden: true
},{
hideLabel: true,
boxLabel: 'Ich akzeptiere die <a href="http://" target="_blank">Link</a>.',
xtype: 'checkbox',
name: 'checkbox',
width: 340,
allowBlank:false
}],
buttons:
[{
text: 'Senden',
handler: function()
{
myForm.getForm().submit({
success: function(){
alert('done');
}
});
}
},{
text: 'Abbrechen',
handler: function()
{
win.hide();
}
}]
});

button.on('click', function()
{
if(!win)
{
win = new Ext.Window
({
applyTo:'window',
layout:'fit',
width:370,
height:370,
closeAction:'hide',
resizable:false,
plain: true,
closable:false,
items: [myForm]
});
}
win.show(this);
});
});

mave
14 Aug 2009, 1:53 AM
hey, i did that... but i have the problem that it is working in firefox but not in ie... why??? if i press submit without filling out the input fields the right msg shows up... but if i put everything in and it should go to submit it it wont...

I get the following error after pressing 'submit' (with input fields filled out!):

Details zum Fehler auf der Webseite

Benutzer-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; InfoPath.2; .NET CLR 3.0.04506.30; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)
Zeitstempel: Fri, 14 Aug 2009 09:51:32 UTC

Meldung: Syntaxfehler
Zeile: 7
Zeichen: 96338
Code: 0
URI: http://localhost/root/ext/ext-all.js


Ext.onReady(function () {

Ext.BLANK_IMAGE_URL = 'ext/resources/images/default/s.gif';

// aktivierung der quicktips
Ext.QuickTips.init();

// validation fehler an der seite anzeigen
Ext.form.Field.prototype.msgTarget = 'qtip';

// variable win
var win;

// variable button
var button = Ext.get('show_window');

// variable formular
var myForm = new Ext.FormPanel({

// eigenschaften formular
// url: 'php/myform.php',
labelWidth: 75,
frame: true,
title: 'Bitte geben Sie Ihre Adressdaten ein:',
bodyStyle: 'padding:5px 5px 0',
width: 400,
defaults: {
width: 230
},
defaultType: 'textfield',

// items formular
items: [{
fieldLabel: 'Apotheke',
name: 'apotheke',
allowBlank: false
},
{
xtype: 'combo',
displayField: 'state',
name: 'salutation',
store: ['Frau', 'Herr'],
typeAhead: true,
mode: 'local',
forceSelection: true,
triggerAction: 'all',
emptyText: 'Please select...',
selectOnFocus: true,
allowBlank: false
},
{
fieldLabel: 'Vorname',
name: 'vorname',
allowBlank: false
},
{
fieldLabel: 'Nachname',
name: 'nachname',
allowBlank: false
},
{
fieldLabel: 'Strasse',
name: 'strasse',
allowBlank: false
},
{
fieldLabel: 'PLZ',
name: 'plz',
width: 50,
maxLength: 5,
minLength: 5,
allowBlank: false,
xtype: 'numberfield'
},
{
fieldLabel: 'Ort',
name: 'ort',
allowBlank: false
},
{
fieldLabel: 'E-Mail',
name: 'email',
vtype: 'email',
allowBlank: false
},
{
hidden: true
},
{
hideLabel: true,
boxLabel: 'Ich akzeptiere die <a href="http://" target="_blank">Link</a>.',
xtype: 'checkbox',
name: 'checkbox',
width: 340,
allowBlank: false
}],

// buttons formular
buttons: [{
text: 'Senden',
handler: function () {
myForm.getForm().submit({
url: 'php/myform.php',
success: function (){
Ext.Msg.alert('Done', 'Form successfully sent!');
},
failure: function (){
Ext.Msg.alert('Failure', 'Form fields may not be submitted with invalid values!');
}
});
}
},
{
text: 'Abbrechen',
handler: function () {
win.hide();
}
}]
});

// bei klick auf button fenster öffnen
button.on('click', function () {
if (!win) {
win = new Ext.Window({
applyTo: 'window',
layout: 'fit',
width: 370,
height: 370,
border: false,
closeAction: 'hide',
resizable: false,
plain: true,
closable: false,
items: [myForm]
});
}
win.show(this);
});
});