帮助记录集和用户输入的值 [英] help with recordsets and user entered values

查看:77
本文介绍了帮助记录集和用户输入的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,感谢您的帮助。


我现在已经和这个问题斗争了几天,经过多次不成功的研究,我仍在寻找答案。所以这就是。我在包含从mySQL数据库中提取的记录集的表单上有9个隐藏字段(qty12,24,36,72,144,288,576,1008,2016)。数据库中的值是......(现在我们遇到了问题。)我有一个名为quantity的文本框,用户可以输入他们想要的特定产品的数量。如果用户输入小于或等于12的数字,则必须乘以qty12(如果其13-24必须使用记录集qty24),如果它在25-36之间则必须使用qty36,依此类推至2016年。这是我到目前为止所写的内容,我们非常感谢任何帮助。

展开 | 选择 | Wrap < span class =codeDivider> | 行号

解决方案

< blockquote>你需要使用parseInt将字符串转换为整数。


在第12行,它应该是< =,而不是> =。另外,使用有意义的变量名称总是一个好主意。


您可能可以使用数组缩短代码,但在这种情况下,它只是可管理的,所以if语句应该没问题。


acoder感谢快速回复。我是新的javascript编程,我不完全确定你的意思。 parseint函数转换哪个字符串?用户输入的数量?还是记录集?关于有意义的变量,我得到你所说的。我现在要改变它们。



您需要使用parseInt将字符串转换为整数。 />

在第12行,它应该是< =,而不是> =。另外,使用有意义的变量名称总是一个好主意。


您可能可以使用数组缩短代码,但在这种情况下,它只是可管理的,所以if语句应该没问题。


用户输入的数量,例如

展开 | 选择 | 换行 | 行号


Hello to all and thanks for your help in advance.

I am having been fighting with this problem for a couple of days now and after much unsuccessful research, I am still looking for an answer. So here it is. I have 9 hidden fields(qty12,24,36,72,144,288,576,1008,2016) on a form containing recordsets pulled from a mySQL database. The values from the database are there... (now we get to the problem.) I have a text box called quantity where a user inputs how many of a particular product they desire. if the user enters a number less than or equal to 12 it has to be multiplied by qty12 if its 13-24 it must use recordset qty24, if its between 25-36 it must use qty36 and so on all the way out to 2016. This is what I have written so far any help would be greatly appreciated.

Expand|Select|Wrap|Line Numbers

解决方案

You need to use parseInt to convert a string into an integer.

On line 12, it should be <=, not >=. Also, it''s always a good idea to use meaningful variable names.

You could probably shorten the code using arrays, but in this case, it''s just about manageable, so should be OK with the if-statements.


acoder thanks for the speedy reply. i am new javascript programming and i am not completely sure what you mean. the parseint functions converts which string? the user entered quantity? or the recordset? about the meaningful variables i get what you''re saying. i will be changing those now.



You need to use parseInt to convert a string into an integer.

On line 12, it should be <=, not >=. Also, it''s always a good idea to use meaningful variable names.

You could probably shorten the code using arrays, but in this case, it''s just about manageable, so should be OK with the if-statements.


The user entered quantity, e.g.

Expand|Select|Wrap|Line Numbers


这篇关于帮助记录集和用户输入的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆