javascript - 在onsubmit中调用javascript函数

标签 javascript function

所以我在javascript中定义了这个函数..

function varReplace(formid)
{
    if (formid.factsc[0].checked == true) {
        formid.adddetails.value == "it's working";
    }
    else {
        formid.adddetails.value == "it's not working";
    }
}   

如果 html 中的factsc被点击“yes”,我想给adddetails一个特定的值。

在 html 方面,我这样调用该函数..

onsubmit="return varReplace(this.form)"

但是它不起作用..任何帮助将不胜感激!提前致谢!

最佳答案

您的函数没有返回任何内容。

Note that in order to cancel the submit event, the onSubmit should be in the form onSubmit="return expression". "return" indicates that the value of the expression should be returned to the submit routine. If the expression evaluates to false, the submit routine is cancelled; if it is true, the submit routine goes forward.

关于javascript - 在onsubmit中调用javascript函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5111573/

相关文章:

javascript - 根据用户计算机的性能禁用 JavaScript 功能

javascript - 如何在 ionic 3 中实现 LinkedIn 登录?为什么 Linked In Login 不起作用?

javascript - Fotorama 4. 滑动超过 1 张图像

javascript - 响应嵌套 json

Python3 : what are faster, 嵌套函数调用或 if 语句(try/excepts 非常快)

javascript - 使用 `react-bootstrap` 和 `npm`

php - 在 foreach 里面返回简码

python - 整数([x[,基数]])。 Python 文档中函数中的方括号?

JavaScript 函数格式

javascript - 无法使用socketIO获取对象内部函数的值