EasyUI Forum
December 21, 2025, 10:39:51 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Programmatically Construct Form within Window  (Read 5912 times)
poeziafree
Jr. Member
**
Posts: 69


View Profile Email
« on: February 18, 2022, 07:39:00 AM »

Hello

I create the Window using javascript through this code:

Code:
$('#win').window({
    width:600,
    height:400,
    modal:true
});

Now I need to create the form inside this window content. But I don't want to load the html form using ajax call from server.

Is there any way to programmatically create the form with its fields and submit function and append that to the window content?

Thank you very much in advance!
Logged
jarry
Administrator
Hero Member
*****
Posts: 2305


View Profile Email
« Reply #1 on: February 21, 2022, 01:39:07 AM »

Please refer to the code below.
Code:
$('#win').window({
width: 400,
height: 400,
modal: true
});
var f = $('<form style="padding:20px"></form>').appendTo('#win');
var wrap = $('<div style="margin-bottom:20px"></div>').appendTo(f);
var field = $('<input name="name" style="width:100%">').appendTo(wrap).textbox({
label: 'Name:',
required: true
});
wrap = $('<div style="margin-bottom:20px"></div>').appendTo(f);
field = $('<input name="email" style="width:100%">').appendTo(wrap).textbox({
label: 'Email:',
required: true,
validType: 'email'
});
var bar = $('<div style="text-align:center"></div>').appendTo(f);
var btn = $('<a href="javascript:;">Submit</a>').appendTo(bar).linkbutton({
width: 100,
onClick: function(){
f.form('submit')
}
})
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!