EasyUI Forum
April 29, 2024, 09:31:56 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: Form update data use switchbutton  (Read 9256 times)
James
Jr. Member
**
Posts: 52


View Profile Email
« on: April 12, 2016, 07:33:53 PM »

I have set switchbutton value = 1,
when use $('#form').form('load',data) to load form data,
if data item value is 0,
it will update switchbutton value to 0,
and now no metter you check or uncheck switchbutton,
ths data you post to server will always be 0
Logged
James
Jr. Member
**
Posts: 52


View Profile Email
« Reply #1 on: April 12, 2016, 07:39:41 PM »

I think this switchbutton should have onvalue and offvalue to attach to onText and offText
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #2 on: April 12, 2016, 08:24:34 PM »

The switchbutton acts as the checkbox. Calling 'load' method of form does not change the value of switchbutton. Please look at this example http://jsfiddle.net/zxxqus10/1/.
Logged
James
Jr. Member
**
Posts: 52


View Profile Email
« Reply #3 on: April 12, 2016, 11:07:36 PM »

The switchbutton acts as the checkbox. Calling 'load' method of form does not change the value of switchbutton. Please look at this example http://jsfiddle.net/zxxqus10/1/.

try this code

Code:
<!DOCTYPE HTML>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="renderer" content="webkit">
<link rel="stylesheet" type="text/css" href="http://www.jeasyui.com/easyui/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="http://www.jeasyui.com/easyui/themes/icon.css">
<link rel="stylesheet" type="text/css" href="http://www.jeasyui.com/easyui/themes/color.css">
<link rel="stylesheet" type="text/css" href="http://www.jeasyui.com/easyui/demo/demo.css">
<script type="text/javascript" src="http://code.jquery.com/jquery-1.6.min.js"></script>
<script type="text/javascript" src="http://www.jeasyui.com/easyui/jquery.easyui.min.js"></script>
<title>text win form</title>
</head>
<body>
<div id="win"></div>
</body>
<script>
    $('#win').window({
href:'form.html',
        width:600,
        height:400,
        modal:true
    });
</script>
</html>

form.html
Code:
<button id="b1"> Load1 </button>
<button id="b2"> Load2 </button>
<button id="b3"> GetFormValue </button>
<form id="form" method="post">
  <table class="form-table">
    <tr>
      <th width="66">label</th>
      <td colspan="7"><input type="text" name="label" class="easyui-textbox" style="width:95%" data-options="required:true" /></td>
    </tr>
    <tr>
      <th>isform</th>
      <td><input name="isform" class="easyui-switchbutton" value="1"></td>
      <th width="66">isrequire</th>
      <td><input name="isrequire" class="easyui-switchbutton" value="1"></td>
      <th width="66">islist</th>
      <td><input name="islist" class="easyui-switchbutton" value="1"></td>
      <th width="66">issearch</th>
      <td><input name="issearch" class="easyui-switchbutton" value="1"></td>
    </tr>
  </table>
</form>
<script>
var d1 = {
"label": "0011",
"isform": "0",
"isrequire": "0",
"islist": "1",
"issearch": "1",
};
var d2 = {
"label": "1010",
"isform": "1",
"isrequire": "0",
"islist": "1",
"issearch": "0",
};
$(function(){
$("#form").form('load', d1);
})
$('#b1').click(function() {
$("#form").form('load', d1);
})
$('#b2').click(function() {
$("#form").form('load', d2);
})
$('#b3').click(function() {
alert($("#form").serialize());
})
</script>
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #4 on: April 13, 2016, 01:15:12 AM »

You call a wrong statement, please remove these lines from your 'form.html' file.
Code:
$(function(){
$("#form").form('load', d1);
})
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!