Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在“中使用变量”;document.Form1.checkbox.checked==true";_Javascript_Variables - Fatal编程技术网

Javascript 在“中使用变量”;document.Form1.checkbox.checked==true";

Javascript 在“中使用变量”;document.Form1.checkbox.checked==true";,javascript,variables,Javascript,Variables,在 我可以用javascript变量替换Form1和checkbox吗 document.Form1.checkbox.checked == true 您可以这样做: var a= checkbox; var b= Form1; document.b.a.checked == true 您还可以为该复选框指定ID,然后使用它 var form = 'Form1'; var field = 'checkbox'; document[form][field].c

我可以用javascript变量替换Form1和checkbox吗

    document.Form1.checkbox.checked == true

您可以这样做:

    var a= checkbox;
    var b= Form1;
    document.b.a.checked == true
您还可以为该复选框指定ID,然后使用它

var form = 'Form1';
var field = 'checkbox';

document[form][field].checked == true

@没人知道这个问题有点具体,我认为你没有同样的问题。请创建新问题并在那里显示您的代码。别担心,我遇到了自己的解决方案:)
document.getElementById('checkbox1').checked == true