使用<form> tage输入相同格式的两个日期

时间:2018-01-20 09:12:37

标签: javascript php jquery html json

我希望通过以下代码从具有相同格式的用户获得两个日期(日期格式为JALAL):((主要部分为粗体))

t = [collections.ChainMap({'a': 'ITT002', 'b': {'c': '2', 'd': '2', 'e': '2'}, 'f': '2'}, {'g': {'h1': {'i': '22', 'j': '2', 'k': '2', 'l': '2', 'n': '2'}}})]
print(json.dumps(dict(t[0])))
>>{"f": "2", "g": {"h1": {"i": "22", "j": "2", "k": "2", "l": "2", "n": "2"}}, "b": {"c": "2", "d": "2", "e": "2"}, "a": "ITT002"}

但JALALI格式仅适用于第一个输入,第二个输入更改为格里高利日期。所有&#34;输入&#34;是相同的!!!!!

2 个答案:

答案 0 :(得分:0)

您不能像这样调用.setup方法,Javascript对象不能有重复的键。您必须分别为每个输入调用它:

Calendar.setup({
  inputField: 'inputpicker',
  button: 'inputpicker',
  ifFormat: '%Y-%m-%d',
  dateType: 'jalali',
  weekNumbers: false
});

Calendar.setup({
  inputField: 'inputpickerr',
  button: 'inputpickerr',
  ifFormat: '%Y-%m-%d',
  dateType: 'jalali',
  weekNumbers: false
});

此外,如果inputFieldbutton键确实包含ID,那么您还有另一个问题 - HTML中的ID必须是唯一的。

答案 1 :(得分:0)

谢谢你的回答 你是对的,我忘了告诉那个主题:我添加&#34; inputField:&#39; inputpickerr&#39;,   按钮:&#39; inputpickerr&#39;,&#34;棘手的。该部分的原文是:

<script type="text/javascript">
        Calendar.setup({
            inputField: "inputpicker",   // id of the input field
            button         :    "inputpicker",   // trigger for the calendar (button ID)ID)
            ifFormat       :    "%Y-%m-%d",       // format of the input field
            dateType       :    'jalali',
            weekNumbers    : false
        });
   </script>

你有解决我问题的方法吗?