首页 > django > Django Button Multiple Actions in one

Django Button Multiple Actions in one

2010-08-23 djangoforms

问题

如何为一个Button分配多个动作:

  1. 时间戳
  2. 一个href到下一页
  3. 根据您单击的位置指定数值。

在Django。

ONCLICK。

怎么可能?

在Html中

在Django Views中

并且时间戳需要记录在用户浏览器(当他点击时)而不是当它到达服务器时。

谢谢。

解决方法

我真的没有看到多个动作。我也无法想象需要获取用户点击时间的时间戳,而不是请求到达服务器时,是否真的重要?如果是这样,您可以在JavaScript中创建时间戳,并在表单上设置隐藏字段或沿着这些行设置隐藏字段。

此外,使用<input type="image" />它将通过他们点击提交表单的地方。

对于href到下一页......我不确定你在这里问什么。在表单上放置一个带有下一页值的隐藏字段?或者只是在Django视图中进行重定向。

问题

How can i assign to one Button multiple actions:

  1. A Timestamp
  2. A href to next page
  3. Assign a numerical value depending on where you clicked.

In Django.

Onclick.

How is that possible?

in Html

in Django Views

And the timestamp needs to be recorded at the users browser (when he clicks) and NOT when it is arriving at the server.

Thanks you.

解决方法

I don't really see multiple actions here. I also cannot imagine the need to get a timestamp for when a user clicks instead of when the request arrives at the server, does it really matter? If it does, you can just create the timestamp in JavaScript and set a hidden field on your form or something along those lines.

Also, use <input type="image" /> that will pass where they clicked along with submitting the form.

For the href to the next page... i'm not sure what you're even asking about here. Put a hidden field on your form with the next page value? Or just do a redirect in your Django view.

相似信息