一起学习网 一起学习网


PHP页面输出时js设置input框的选中值

网络编程 PHP页面输出时js设置input框的选中值 06-22

关于php页面输出时js设置input框的选中值的代码如下所示:

/* 设置表单的值 */
function setValue(name, value) {
var first = name.substr(0, 1),
input, i = 0,
val;
if (value === "") return;
if ("#" === first || "." === first) {
input = $(name);
} else {
input = $("[name='" + name + "']");
}

if (input.eq(0).is(":radio")) { //单选按钮
input.filter("[value='" + value + "']").each(function() {
this.checked = true
});
} else if (input.eq(0).is(":checkbox")) { //复选框
if (!$.isArray(value)) {
val = new Array();
val[0] = value;
} else {
val = value;
}
for (i = 0, len = val.length; i < len; i++) {
input.filter("[value='" + val[i] + "']").each(function() {
this.checked = true
});
}
} else { //其他表单选项直接设置值
input.val(value);
}
}

以上所述是小编给大家介绍的PHP页面输出时js设置input框的选中值,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对积木网网站的支持!

thinkphp在php7环境下提示Cannot use ‘String’ as class name as it is reserved的解决方法
本文实例讲述了thinkphp在php7环境下提示Cannotuse‘String'asclassnameasitisreserved的解决方法。分享给大家供大家参考,具体如下:我有一网站之前用php7运行think

php opendir()列出目录下所有文件的实例代码
phpopendir()函数用于打开目录,通常与readdir()和closedir()函数一起用来读取目录下所有文件(即遍历目录),本文章向大家介绍php使用opendir()函数列出目录下

浅谈PHP中静态方法和非静态方法的相互调用
在PHP的非静态方法中可以调用静态方法classtest{publicstaticfunctionstrPrint(){echo'thisisstrPrintstaticfunctionbr';}publicfunctionstaticFuncInvoke(){self::strPrint();}}$test=newtest();$t


编辑:一起学习网

标签:静态,方法,函数,给大家,表单