如何更改复选框到图像以删除元素(How to change checkbox to image for deleting elements)
我有一个购物车表单,用户当前可以在他们要删除的项目旁边选中一个框,然后单击按钮进行提交。
我想更改它,以便有一个垃圾桶图标,而不是单击图像本身时删除相应的购物车项目的复选框。
这是复选框函数的Jquery:
function RemoveShoppingCartItem(rcuid, sFormName) { var eForm = document.getElementsByName(sFormName)[0]; document.getElementById('rcuid').value = rcuid; eForm.action += "&Action=REMOVE"; eForm.submit(); }
以及复选框的代码:
<input type="checkbox" value="9681" name="rcuid">
但是每个盒子的价值都会发生变化。
我需要做什么才能获得我需要的结果?
I have a shopping cart form where the user can currently check a box beside the item they wish to remove and click a button to submit.
I want to change it so that there is a trash can icon instead of the check box that removes the corresponding shopping cart item when the image itself is clicked.
Here is the Jquery for the checkbox function:
function RemoveShoppingCartItem(rcuid, sFormName) { var eForm = document.getElementsByName(sFormName)[0]; document.getElementById('rcuid').value = rcuid; eForm.action += "&Action=REMOVE"; eForm.submit(); }
And the code for the checkbox:
<input type="checkbox" value="9681" name="rcuid">
But the value changes for each box.
What exactly do I need to change to get the result I need?
原文:https://stackoverflow.com/questions/20976506
最满意答案
Python 2.7中的
float.__repr__()
和float.__str__()
方法已更改; Python 3.1的浮点到字符串转换方法被反向移植并且值现在被舍入。
float.__str__()
的C源代码将使用g
格式器代码的浮点值格式化为sprintf()
函数,其精度为12位。为了在Python 2.6中得到相同的结果,你必须自己格式化字符串:
'%.12g' % fp_value
或使用
format()
函数:format(fp_value, '.12g')
请注意,在Python 2.7中,只有表示发生了变化,而不是实际值。 浮点值仍然是实数的二进制近似值,而二进制分数并不总是与表示的确切数字相加。
如果你需要比
float
近似值提供的精度更高,则需要切换到使用decimal.Decimal()
类型 。 这以维持速度为代价保持精度(浮点运算在现代计算机上的硬件中处理)。The
float.__repr__()
andfloat.__str__()
methods in Python 2.7 changed; the Python 3.1 float-to-string conversion method was backported and values are now rounded.The C source code for
float.__str__()
formats a floating point value using theg
formatter code to thesprintf()
function, with a precision of 12 positions.To get the same result in Python 2.6, you'll have to format the string yourself:
'%.12g' % fp_value
or use the
format()
function:format(fp_value, '.12g')
Note that in Python 2.7 only the representation changed, not the actual values. Floating point values are still binary approximations of real numbers, and binary fractions don't always add up to the exact number represented.
If you need to have more precision than what
float
approximations offer you, you need to switch to using thedecimal.Decimal()
type instead. This maintains precision, at the cost of speed (floating point arithmetic is handled in hardware on modern computers).
相关问答
更多-
logutils包可能满足您的需求 - 它将某些功能(包括dictConfig()移植到早期的Python版本。 The logutils package might serve your needs - it backports certain functions - including dictConfig() - to earlier Python versions.
-
关于什么: import contextlib def unzip(source, target): with contextlib.closing(zipfile.ZipFile(source , "r")) as z: z.extractall(target) print "Extracted : " + source + " to: " + target __exit__正确地执行了ZipFile上缺少的__exit__方法。 即,调用close方法 What a ...
-
替换系统Python不是一个好主意。 向上移动一点可能不会破坏您的系统,但谁愿意承担风险? 使用easy_install将库安装到系统Python如果相互冲突也会导致问题。 另一种方法是从源代码构建Python,将其安装到您的主目录,并使用virtualenv创建隔离的环境,您可以使用pip为其中的某个项目安装所需的库(这与easy_install更为现代)。 对于Python 2.7,如果你想要一些标准库的“可选”部分,那也意味着要构建其他一些东西。 这是一个脚本(很大程度上是从散布在互联网上的博客文章中 ...
-
看看http://pypi.python.org/pypi/ordereddict 它被宣传为 Py2.7的新集合的替代品.OrderedDict适用于Python 2.4-2.6。 Take a look at http://pypi.python.org/pypi/ordereddict It's advertised as A drop-in substitute for Py2.7's new collections.OrderedDict that works in Python 2.4-2.6. ...
-
你可以使用str.split方法: >>> '001 abcdef 001'.split(None, 1) # `1` to split at most once ['001', 'abcdef 001'] >>> '001 abcdef 001'.split(None, 1)[1] 'abcdef 001' (使用None来分割任何连续的空格) 问题的第二个结果的可能原因是您剪切已经剪切的字符串。 (不是因为Python 2.6和Python 2.7之间的区别) >>> '001 abcdef 00 ...
-
rpm仅检查rpmdb是否存在依赖关系。 由于你的rpmdb声称拥有2.6,所以它无法实现2.7依赖。 改用pip来安装模块。 rpm only examines the rpmdb for dependencies. Since your rpmdb claims to have 2.6, there's no way it can fulfill the 2.7 dependency. Use pip to install the module instead.
-
在python 2.6和python 2.7上使用随机的不同浮点精度(different float precision using random on python 2.6 vs python 2.7)[2022-08-30]
random()返回的数字是相同的。 它的显示精度是不同的。 这是我的Python 2.7返回的前两个数字,但显示的默认值更多十进制数字: $ python Python 2.7.3 (default, Sep 26 2013, 20:03:06) [GCC 4.6.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import random >>> rng = random.Ra ... -
Python 2.7中的float.__repr__()和float.__str__()方法已更改; Python 3.1的浮点到字符串转换方法被反向移植并且值现在被舍入。 float.__str__()的C源代码将使用g格式器代码的浮点值格式化为sprintf()函数,其精度为12位。 为了在Python 2.6中得到相同的结果,你必须自己格式化字符串: '%.12g' % fp_value 或使用format()函数: format(fp_value, '.12g') 请注意,在Python 2.7 ...
-
看起来原因是我以root身份安装了软件包。 干 sudo chmod -R ugo+rX /usr/local/lib/python2.7/site-packages 解决了这个问题 Looks like the reason was that I installed the packages as root. Doing sudo chmod -R ugo+rX /usr/local/lib/python2.7/site-packages fixed the problem
-
为什么我不能从usr / lib /中删除python 2.6和2.7?(Why can I not remove python 2.6 and 2.7 from usr/lib/?)[2023-04-20]
这是由于Apple在OSX版本El Capitan及其后续版本中引入的系统完整性保护 。 It is due to System Integrity Protection, introduced by Apple on OSX versions El Capitan and onwards.