html 计算小数有误,Javascript错误:SyntaxError:小数点后必须出现至少一个数字

本文介绍了一位初学者在使用HTML表单结合AJAX进行实时更新时遇到的小数点语法错误,并给出了修复建议。当表单字段的ID包含字母和特殊字符时,正确的做法是用引号将整个ID包裹起来,明确标识为字符串。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

I'm trying to setup an html form to perform an AJAX update when a user exits a field. I've only tried to set this up on one table cell at the moment as follows:

我正在尝试设置一个html表单,以便在用户退出字段时执行AJAX更新。我目前只尝试将其设置在一个表单元格上,如下所示:

However I'm getting an error as follows:

但是我得到的错误如下:

SyntaxError: At least one digit must occur after a decimal point

SyntaxError:小数点后必须出现至少一个数字

If I change the cell to something like this:

如果我把单元格改成这样:

it works. However I need to use the longer ID string as that is the record ID required for the database update and I cannot change the format of this string.

它的工作原理。但是,我需要使用较长的ID字符串,因为这是数据库更新所需的记录ID,我不能更改此字符串的格式。

I'm new to Javascript and AJAX so not sure what could be the issue with the longer string? There's no decimal points that I can see either.

我是Javascript和AJAX新手,所以不确定长字符串会有什么问题?我也看不到小数点。

1 个解决方案

#1

3

Due to content of 1E1DDA14-D2C6-4FC8-BA5F-DBCCC7ABAF7F having letters and - characters, you need to wrap it in quotes to denote it as a string literal:

由于1E1DDA14-D2C6-4FC8-BA5F-DBCCC7ABAF7F的内容有字母和-字符,所以需要用引号将其括起来,表示为字符串文字:

οnchange="updateRecord('1E1DDA14-D2C6-4FC8-BA5F-DBCCC7ABAF7F')"

Unqouted and not numeric, JavaScript is expecting a variable or other object (null, false etc). Your 12345 test works because it only contains numbers.

不符合查询,而不是数字,JavaScript希望得到一个变量或其他对象(null, false等)。您的12345测试工作,因为它只包含数字。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值